1. 进入容器内部后
lcc@lcc ~$ docker exec -it docker_mysql bash
root@b3b1d61142df:/#
root@b3b1d61142df:/# cat /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.2 b3b1d61142df
root@b3b1d61142df:/#
会显示自己以及(– link)软连接的容器IP
2.使用命令
docker inspect --format '{
{ .NetworkSettings.IPAddress }}' <container-ID>
lcc@lcc ~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS