How to Get IP Address of A Docker Container

Channel: Linux
Abstract: you have a docker container with the container id 1808352f0693. Just run the below command on terminal. docker inspect -f '{{range .NetworkSettings.Ne

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}}' <CONTAINER ID/NAME>
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

Ref From: tecadmin

Related articles