When running Docker for Windows and Docker for macOS, we get these handy aliases like docker.for.mac.localhost, docker.for.mac.internal, docker.for.win.localhost and docker.for.win.internal. Unfortunately, when my projects are being worked on between macOS and Windows, someone has to go changing any of these host names for the specific platform they're on, despite the premise of the two being the same!

The fact that these two things that accomplish the exact same outcome are named differently is unhelpful. Is there any way we can get a new convention like docker.internal and docker.localhost? Would it also be possible to simply have them resolve localhost when used on Linux which obviously doesn't have the extra layer going on? The name of the game here is that I need my containers to have a consistent way to reference not the VM, but the actual physical hardware they're running on. Bonus points if it's a consistent IP address so that I can configure my own DNS aliases!

Docker.for.mac.localhost

Moreover, would it be possible either with or without my suggested change to get all these magic hostnames documented somewhere? They seem to be rather un-googleable and largely defined by anecdotal knowledge rather than being clearly offered.

Docker.for.mac.localhost

Docker Port Localhost

This information is as of 2018-03-31 with Docker 18.03.0-ce I wanted to access host port from a docker container. For example, an nginx process is running on the host machine with port 8888 open, then I would like to create a container which can curl host:8888. I know how to discover container-to-container, but don't know how to get host IP address from a container. Therefore, I wandered the internet. Precondition I mainly use Docker for Mac, but sometimes use Linux. So I want my containers to run on both platform.

Docker Compose Localhost

TL;DR Host networking mode? I found Docker has 'host networking mode'. With this mode, the container seems to be able access to the host with '127.0.0.1'.

So I tried it and it works on my Linux machine, but it didn't work on my Mac. Then I found: The host networking driver only works on Linux hosts, and is not supported on Docker for Mac, Docker for Windows, or Docker EE for Windows Server.

Let me find another way please. I found I can resolve host.docker.internal as the host IP address in the container on Docker for Mac.

Docker Windows Localhost

Docker link localhost

That's what I wanted to know! Where's Linux version of it.? (´・ω・`) NotFound. In addition, I was a little bit confused there're several names:. docker.for.mac.localhost.