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.
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-exporterStep 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_idExample:
$ docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' 29cf6681b479
172.17.0.2The command directly prints the container's IP address.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
DevOps Operations Practice
We share professional insights on cloud-native, DevOps & operations, Kubernetes, observability & monitoring, and Linux systems.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
