meta data for this page
Host access from container
By default it is possible to access host services on host external interfaces (not loopback). Host is available under IP address of Docker network, so dynamic mapping is needed (address can change).
/etc/hosts
Docker can automatically generate /etc/hosts
to provide name resolution of other containers.
This can be extended by:
docker run --add-host=host.docker.internal:host-gateway
- docker-compose.yml
extra_hosts: - "host.docker.internal:host-gateway"
List of usefull DNS aliases:
- host-gateway
- gateway.docker.internal
- host.docker.internal - (already exists on Win and MAC, for Linux manual mapping is needed)
NOTE: Supported in Docker version 20.10.0
loopback access
host network mode
Using host network mode exposes host network stack do container!