docker run --add-host host.docker.internal:host-gateway myimage

Category: Docker

docker run --add-host host.docker.internal:host-gateway myimage

Map a hostname to the Docker host

Adds an entry to the container's /etc/hosts resolving host.docker.internal to the host machine via host-gateway. The pattern lets containers reach host services like databases. Works on Linux, not just Docker Desktop.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.