Category: Docker

You may have been tempted to have the following line in the Dockerfile but it won't work because Docker Daemon manages container's /etc/hosts file.

RUN ....
echo "172.17.0.1 host.docker.internal" >> /etc/hosts

The solution is to use extra hosts parameter to the docker-compose.yml file.

extra_hosts:
  - "some-host:1.2.3.4"

Usually the extra hosts section is used to pass host-gateway's IP which is host's ip the container so the container can connect to the host.

extra_hosts:
  - "host.docker.internal:host-gateway"

Join our mailing list

Get important news about cool products we release and invitations to beta test new products

Find out the Social networks we're on

Black and Cyber Monday Deal: Use blackfriday22 code at checkout for 40% off
Static file optimization by StaticOptimizer