建立一个name为web的nginx容器nginx
docker run --name web -d nginx
因为这个nginx镜像很精简,web容器内部yum、ip、curl、wget、netstat等命令都没有安装。
因此测试web容器的服务是否正常运行了的话,能够尝试在外部主机上进行以下操做。web
docker network ls docker network inspect a61c325bd7ba { "Containers": { "5b567458c87cc1c7eff73d47a753e1171c6478f2705868f01ebd858b196a2283": { "Name": "test1", "EndpointID": "e6710f0db01bdbf3669aabeab866a4f27bf1605226dd3d3c98a8b7ea1c6896f0", "MacAddress": "02:42:ac:11:00:02", "IPv4Address": "172.17.0.2/16", "IPv6Address": "" }, "e1dbb7a9f30a284c080159ad82936c08e567a7160f99029fe1ab2e93b92cc4f4": { "Name": "web", "EndpointID": "4cbb7cabda70785b2244c4f99b21325b43f6115d575b83fdd5369135f6844d8d", "MacAddress": "02:42:ac:11:00:03", "IPv4Address": "172.17.0.3/16", "IPv6Address": "" } } } curl 172.17.0.3
这个时候的web容器是只能在局域网上进行访问的。docker
建立一个name为web2的nginx容器shell
docker run --name web2 -d -p 80:80 nginx
此时在vagrant虚拟主机上经过以下命令便可访问curl
curl 127.0.0.1
由Vagrantfile中的配置可知,咱们在宿主机上,经过以下方式也可访问测试
curl 192.168.205.10