Docker host ip on ubuntu

user1785231 picture user1785231 · Aug 15, 2016 · Viewed 9k times · Source

Its baffling how one get host ip address on windows (boot2docker) by just issuing this command: docker-machine ip

But same doesn't work on ubuntu using same command. It always says : "docker-machine: command not found"

Any idea on why its not working? or is there different command to find the host ip while running ubuntu as the host machine os and docker host?

Answer

Luis Govea picture Luis Govea · Aug 15, 2016

Instead of using docker-machine commands you could use regular docker commands.

For example if you run the following container

docker run --name some-postgres -p 5432:5432 -d postgres

You can access the container through localhost in port 5432 or you can use docker inspect to find the containers IP

docker inspect --format '{{ .NetworkSettings.IPAddress }}' some-postgres