container snippets

How to access the host from a docker container

Tagged container, docker, host, ip  Languages bash

Access host from docker container IP:

# Mac
ping docker.for.mac.localhost

# Windows
ping docker.for.win.localhost

# Linux: use the hosts external IP, see:
# https://github.com/docker/for-linux/issues/264#issuecomment-385698947

Note that it’s not possible to use host networking on Mac or Windows, only Linux:

The host networking driver only works on Linux hosts, and is not supported on Docker Desktop for Mac, Docker Desktop for Windows, or Docker EE for Windows Server.

See: