docker inspect node1 |grep IPAddress |tail -1 |awk ‘{print $2}‘ |tr ‘"‘ " " |tr ‘,‘ ‘ ‘ # 可以用容器id或名称
方法二:
docker inspect --format ‘{{ .NetworkSettings.IPAddress }}‘ node1 # 容器id或者名称
显示所有容器的IP
docker inspect --format=‘{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}‘ $(docker ps -aq) /node1 - 172.17.0.15/n11 - 172.17.0.14/n10 - 172.17.0.13/n9 - 172.17.0.12/n8 - 172.17.0.11/n7 - 172.17.0.10/n6 - 172.17.0.9/n5 - 172.17.0.8/n4 - 172.17.0.7/n3 - 172.17.0.6/n2 - 172.17.0.5/n1 - 172.17.0.4
原文地址:https://www.cnblogs.com/kaishirenshi/p/10375203.html
时间: 2024-10-31 00:02:57