Cloud Native 3 min read

How to Find the IP Address of a Docker Container

This guide explains how to quickly retrieve the IP address of a running Docker container using simple commands such as `docker ps`, `docker inspect`, and a formatted inspect query, with step‑by‑step instructions and example output for easy debugging and network configuration.

DevOps Operations Practice
DevOps Operations Practice
DevOps Operations Practice
How to Find the IP Address of a Docker Container

When using Docker containers, you may need to know the IP address of a specific container for debugging, network configuration, or connecting to services running inside the container.

This guide shows how to easily find a Docker container's IP address using simple commands.

Step 1: List Docker containers

First, list all running containers to obtain the container ID or name:

docker ps

Example output:

$ docker ps
CONTAINER ID   IMAGE                              COMMAND                  CREATED        STATUS        PORTS                                       NAMES
29cf6681b479   bitnami/blackbox-exporter:0.25.0   "/opt/bitnami/blackb…"   17 hours ago   Up 17 hours   0.0.0.0:9115->9115/tcp, :::9115->9115/tcp   blackbox-exporter

Step 2: Inspect the container

Use docker inspect followed by the container ID or name to get detailed information in JSON format, then locate the NetworkSettings section.

docker inspect container_id

In the JSON output, find the NetworkSettings object.

Step 3: Extract the IP address

Locate the IPAddress field under NetworkSettings . You can also filter the output with a formatted inspect command:

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

Example:

$ docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' 29cf6681b479
172.17.0.2

The command directly prints the container's IP address.

Dockernetworkcontainercommand lineIP addressInspect
DevOps Operations Practice
Written by

DevOps Operations Practice

We share professional insights on cloud-native, DevOps & operations, Kubernetes, observability & monitoring, and Linux systems.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.