How do for a Docker container to resolve a HOST DNS name?

Asked

Viewed 483 times

1

On my HOST server I put in the file /etc/hosts the input:

192.168.9.9 server_1

I need you inside a Docker container, if I call: wget server_1:1234 , it accesses port 1234 of ip 192.168.9.9 (is the IP of the HOST) where Docker is installed. I cannot use the --Networks = host directive It would be possible to create a service or edit host iptables?

  • Managed to try the add-host?

1 answer

3

In this case you need to change the container hosts and not the host hosts. The correct way to "change" the container hosts file is with the flag --add-host, according to the documentation of the Docker: https://docs.docker.com/engine/reference/commandline/run/

In this case, you still need to check the IP in the "network" of the Docker and not the IP of the host on the network where it is. This IP varies confirm your operating system, but you can consult it and change it but Docker settings.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.