Docker 如何查看容器IP地址

本文详细指导了在Centos7.5环境中使用Docker 20.10.6查看容器IP地址的方法,包括通过`docker exec`命令和`docker inspect`命令获取,适合Docker新手和运维人员参考。
摘要由CSDN通过智能技术生成

环境:

Centos7.5
docker Version: 20.10.6
vmware 16.0

问题描述:

Docker 如何查看容器IP地址

解决方案:

1.docker exec -it ID/NAMES ip addr

root@localhost ~]# docker exec -it chemex ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
6: eth0@if7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:42:ac:11:00:03 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 172.17.0.3/16 brd 172.17.255.255 scope global eth0
       valid_lft forever preferred_lft forever

2.查看Docker的底层信息,里面也有ip相关

docker inspect ID/NAMES

[root@localhost ~]# docker inspect chemex
  "SandboxKey": "/var/run/docker/netns/097fea0dab2c",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "a0ccbe5d548680eefeebbe56e2466f05851a2e31665959bb83271da769b557a2",
            "Gateway": "172.17.0.1",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "172.17.0.3",
            "IPPrefixLen": 16,
            "IPv6Gateway": "",
            "MacAddress": "02:42:ac:11:00:03",
            "Networks": {
                "bridge": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "185a64b1a5b82471a8b742294e5e2feab3f3a23e52246897decde4378af9bd47",
                    "EndpointID": "a0ccbe5d548680eefeebbe56e2466f05851a2e31665959bb83271da769b557a2",
                    "Gateway": "172.17.0.1",
                    "IPAddress": "172.17.0.3",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:11:00:03",
                    "DriverOpts": null
                }
            }
        }
    }
]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值