Reputation: 2068
I'm using a docker container to run some browser tests.
For some OAuth workflow, I need a custom hostname that I can forward to the OAuth site, for example my.dev.site
.
Usually in non-docker environments, I just add an entry to the /etc/hosts
file that casts my.dev.site
to 127.0.0.1
Is this possible with docker and if so, how?
Upvotes: 0
Views: 688
Reputation: 1303
By default, docker container hosts are identified by their name.
However, in a compose file, you could use extra_host
field to add hostnames to /etc/hosts within containers.
https://docs.docker.com/compose/compose-file/compose-file-v3/#extra_hosts
extra_hosts:
- "my.dev.site:127.0.0.1"
And the docker run version
https://docs.docker.com/engine/reference/run/#network-settings
docker run --add-host my.dev.site:127.0.0.1 <image>
Upvotes: 1