Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker host ip on ubuntu

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?

like image 734
user1785231 Avatar asked Aug 15 '16 12:08

user1785231


People also ask

How do I find my docker host IP address?

You can easily get the IP address of any container if you have the name or ID of the container. You can get the container names using the "Docker ps -a" command. This will list all the existing containers.

What is docker localhost IP?

Accessing the Host With the Default Bridge Mode You just need to reference it by its Docker network IP, instead of localhost or 127.0. 0.1 . Most Docker Engine installations will represent the host as 172.17.0.1 on the default docker0 bridge network.

What IP is 172.17 0.1 docker?

Listen to Connections in the Docker Network The bridge connection docker0 – with IP address 172.17. 0.1 – is created by Docker at installation time. Because the host and all containers are connected to that network, our application only needs to listen to it.

How do I find the IP address of a docker container in Linux?

You can use docker inspect <container id> . In order to extract the ip, you can do something like docker inspect $CID | grep IPAddress | cut -d '"' -f 4 , it works fine :) Just a note.


1 Answers

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
like image 192
Luis Govea Avatar answered Sep 28 '22 05:09

Luis Govea