November 2017
Intermediate to advanced
298 pages
7h 10m
English
In some specific configurations, you may have a host on your network that needs to be mapped or re-mapped to a specific IP address for the container that is trying to reach it. This allows a flexible configuration of named servers and can be a real life-saver for static hosts on the network without a good network DNS server.
To add such a host mapping to a container, you can run the container with docker run --add-host and using this flag, an entry in /etc/hosts is added that matches your input so that you can properly route your requests to it:
$ # Show what the default /etc/hosts has$ docker run --rm \ -it \ ubuntu \ /bin/cat /etc/hosts127.0.0.1 localhost::1 localhost ip6-localhost ip6-loopbackfe00::0 ip6-localnet ...
Read now
Unlock full access