根底版
创立一个name为web的nginx容器
docker run --name web -d nginx
因为这个nginx镜像很精简,web容器外部yum、ip、curl、wget、netstat等命令都没有装置。
所以测试web容器的服务是否失常运行了的话,能够尝试在内部主机上进行如下操作。
docker network lsdocker 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容器是只能在局域网上进行拜访的。
升级版
创立一个name为web2的nginx容器
docker run --name web2 -d -p 80:80 nginx
此时在vagrant虚拟主机上通过如下命令即可拜访
curl 127.0.0.1
由Vagrantfile中的配置可知,咱们在宿主机上,通过如下形式也可拜访
curl 192.168.205.10