基础版
创建一个name为web的nginx容器
docker run --name web -d nginx
由于这个nginx镜像很精简,web容器内部yum、ip、curl、wget、netstat等命令都没有安装。
所以测试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容器是只能在局域网上进行访问的。
升级版
创建一个name为web2的nginx容器
docker run --name web2 -d -p 80:80 nginx
此时在vagrant虚拟主机上通过如下命令即可访问
curl 127.0.0.1
由Vagrantfile中的配置可知,我们在宿主机上,通过如下方式也可访问
curl 192.168.205.10
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。