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"