Docker Community Forums

In the past with docker-machine I could run the following command to determine the IP address:

docker-machine ip default

This proved a convenient way to setup env vars within shell scripts so I could do things like run psql from host and access the postgres container being used by my app.

Disclaimer: I realize that docker.local is supposed to be a shortcut way to avoid using IP addresses with Docker for Mac, but for me it currently does not work when connected through VPN. I am sure that will be fixed eventually.

In the interim, and as part of my transition from docker-machine centric scripts, the question I would like guidance on is how do you get the IP address of xhyve docker instance?

Not sure if there is a specific reference point to go to, but read the docs on the beta getting started page, and it is mentioned near the bottom when verifying if Docker for Mac is running successfully.

@hoshposh Moving forward we’ll be using localhost as the source of truth instead of docker.local
This should allow your running host scripts to use localhost without having to do the leg work of getting the IP.

But what if you want an IP that is accessible by other containers from both a browser on the host side (Mac) and from for container to container communication on the Docker host side (xhyve/alpine). It isn’t clear now how to find the host ip of the xhyve VM.

I know containers should access each other by name (requires being on the same network) but it’s convenient to access by the published ip/port, and something like that is necessary if you’re trying to use a container (such as a build cache) from docker build.