This tutorial will help you to get the IP address of a Docker container on your system. The docker binary provides network option to manage networking for the docker environment. Also, you can use inspect option to find the details of a Docker container. In this tutorial, we use inspect option to fetch docker container IP address via command line.

Syntax

Use below syntax to get IP address of a Docker container. You need to change CONTAINER ID/NAME with the actual container ID or name.

docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' 

Example

For example, you have a docker container with the container id 1808352f0693. Just run the below command on terminal.

docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' 1808352f0693

Output

172.17.0.2

How to Get IP Address of A Docker Container General Articles

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..