Get the IP addresses of local Docker containers

Reading time: 13 – 21 minutes

We have Docker running with containers that are connected to their own private network. To efficiently manage and monitor these containers, it’s often useful to retrieve their private IP addresses.

With the following command, you can easily obtain the private IP addresses of all running Docker containers:

sudo docker inspect $(docker ps -q) --format='{{ printf "%-50s" .Name}} {{range .NetworkSettings.Networks}}{{.IPAddress}} {{end}}' | sort -t. -k2,2n -k3,3n -k4,4n

Output example:

$ sudo docker inspect $(docker ps -q ) --format='{{ printf "%-50s" .Name}} {{range .NetworkSettings.Networks}}{{.IPAddress}} {{end}}' | sort -t. -k2,2n -k3,3n -k4,4n
/rproxy                                            10.3.10.2
/n8n                                               10.3.10.4
/semaphore                                         10.3.10.6
/code                                              10.3.10.7
/ssh                                               10.3.10.9
/nodered                                           10.3.10.11
/pihole_opendns                                    10.3.10.23
/pihole_googledns                                  10.3.10.24

Últimas entradas

Archivo
Scroll to Top