List Docker Containers' IPs

2019年7月2日 3804点热度 1人点赞 2条评论
内容目录

Method to check the IP of a specific container

docker inspect <container ID> | grep IPAddress

Check Docker names:

sudo docker inspect -f='{{.Name}}' $(sudo docker ps -a -q)

Check Docker's IP:

sudo docker inspect -f='{{.NetworkSettings.IPAddress}}' $(sudo docker ps -a -q)

Based on the above, we can write the following script to list all containers with their corresponding names, ports, and IPs

 docker inspect -f='{{.Name}} {{.NetworkSettings.IPAddress}} {{.HostConfig.PortBindings}}' $(docker ps -aq)

About inspect: https://www.cnblogs.com/boshen-hzb/p/6376674.html

痴者工良

高级程序员劝退师

文章评论