Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

How to Get the IP Address of a Docker Container?

  • Last Updated : 28 Oct, 2020

If you want multiple Docker Containers to talk to each other, they can form a Bridge Network. Each Container Network has its own Subnet mask to distribute IP addresses. The default subnet for a Docker Network is 172.17.0.0/16

In this article, we are going to discuss the different ways you can use to know the IP address of a Docker Container.

Method 1: Using the Bash

Start the Bash of the Container.

sudo docker exec -it 6cb599fe30ea bash

Running the bash

Install iproute2 to use the ip command.

apt-get install iproute2

Use this command to get the IP address.



ip add | grep global
Using the Bash

Method 1: Using the Bash

Method 2: Direct Command

You can get the IP address of the Docker Container directly using this command. You need to have the Container ID to use this method.

sudo docker exec -it 6cb599fe30ea ip addr | grep global
 Direct Command

Method 2:  Direct Command

Method 3: Using Docker Inspect

You can also use the Docker Inspect command to return the IP address of the Docker Container. 

sudo docker inspect --format '{{ .NetworkSettings.IPAddress }}' 6cb599fe30ea
 Using Docker Inspect

Method 3:  Using Docker Inspect

To conclude, in this article we discussed three different ways to find out the IP address of a Docker Container. Methods 2 and 3 require less effort and using a single line command, you can easily find out the IP address of the container if you have it’s Container ID.

My Personal Notes arrow_drop_up
Recommended Articles
Page :