Manual set up two containers by “docker run”
安装docker步骤此处忽略,详细可以看之前的文章;
容器的网络类型
默认docker三种网络:
[root@localhost ~]# docker network ls
NETWORK ID NAME DRIVER SCOPE
0dc7621fa6c0 bridge bridge local
09d08085f98c host host local
8da76deb9eb9 none null local
先随便开一个centos的docker,“-t” 指定一个伪终端,保持docker可以打开,否则会出现“Exited (0)”的问题:
[root@localhost ~]# docker run --name centos -dt centos
查看容器的网络类型,可以看到当创建容器不指定网络类型,默认会绑定到bridge上:
[root@localhost ~]# docker inspect 355a |grep "Networks" -A 100
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "0dc7621fa6c0e40a1129104ed94deac543cf82ce44ab79fdf7ed38b9975f9a78",
"EndpointID": "2dae4a431efd76066081424e47a7e6bc53e4102b14bf36bbdfda34492efd6369",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:02",
"DriverOpts": null
完整阅读