docker inspect --format '{{ .NetworkSettings.IPAddress }}' <container-ID>
或
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container_name_or_id
示例:
docker inspect --format '{{ .NetworkSettings.IPAddress }}' activemq
显示所有容器IP
docker inspect --format='{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq)
网友评论