赞
踩
给容器一个网络来运行实例
例:
[root@server ~]# docker images
[root@server ~]# docker run --net none -it -d --name testnet01 centos:7.2.1511 /bin/bash
[root@server ~]# docker exec -it testnet01 /bin/bash
[root@e3bcb6d230d2 /]# ping www.baidu.com
ping: unknown host www.baidu.com
[root@e3bcb6d230d2 /]# exit
[root@server ~]# docker commit testnet01 testnet01-1:2.1
[root@server ~]# docker images
[root@server ~]# docker run -itd --name test102 testnet01-1:2.1 /bin/bash
[root@server ~]# docker exec -it test102 /bin/bash
[root@79d441c7d5dc /]# ping www.baidu.com
PING www.baidu.com (183.232.231.172) 56(84) bytes of data.
64 bytes from 183.232.231.172: icmp_seq=1 ttl=56 time=14.3 ms
64 bytes from 183.232.231.172: icmp_seq=2 ttl=56 time=15.1 ms
64 bytes from 183.232.231.172: icmp_seq=3 ttl=56 time=14.3 ms
^C
--- www.baidu.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2005ms
rtt min/avg/max/mdev = 14.322/14.601/15.121/0.380 ms
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。