How to list all Docker containers, just name & network interface name
The following command will list all running Docker containers with their names, network interface (bridge interface) names, and IP addresses:
docker ps -a --format "{{.Names}}" | xargs -I {} docker inspect --format "{{.Name}} {{range .NetworkSettings.Networks}}br-{{slice .NetworkID 0 12}} {{.IPAddress}}{{end}}" {}
Example output
/mycontainer1 br-a1b2c3d4e5f6 192.168.1.2
/web-server br-b2c3d4e5f6a1 172.17.0.3
/database-prod br-c3d4e5f6a1b2 10.0.0.15
/redis-cache br-d4e5f6a1b2c3 192.168.100.8
/nginx-proxy br-e5f6a1b2c3d4 172.20.0.4
/api-backend br-f6a1b2c3d4e5 10.1.1.23
/monitoring-stack br-1a2b3c4d5e6f 192.168.50.12
/elasticsearch-node br-2b3c4d5e6f1a 172.18.0.7
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow