How to resolve docker host names (/etc/hosts) in containers -


how possible resolve names defined in docker host's /etc/hosts in containers? containers running in docker host can resolve public names (e.g. www.ibm.com) docker dns working fine. resolve names docker hosts's (e.g. 127.17.0.1 smtp) containers.

my final goal connect services running in docker host (e.g. smtp server) containers. know can use docker host ip (127.17.0.1) containers, thought docker have used docker host /etc/hosts build containers's resolve files well.

i quite sure have seen working while ago... wrong.

any thoughts?

giovanni

check out --add-host flag docker command: https://docs.docker.com/engine/reference/run/#managing-etchosts

$ docker run --add-host="smtp:127.17.0.1" container command

in docker, /etc/hosts cannot overwritten or modified @ runtime (security feature). need use docker's api, in case --add-host modify file.

for docker-compose, use extra_hosts option.

for whole "connect services running in host" problem, see discussion in github issue: https://github.com/docker/docker/issues/1143.

the common approach problem use --add-host docker's gateway address host, e.g. --add-host="dockerhost:172.17.42.1". check issue above scripts find correct ip , start containers.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -