第一次啓動還正常呢,第二次啓動就不能夠了。python
[root[@xxxxxx](https://my.oschina.net/xxww) ~]# docker run -d -P training/webapp python app.py WARNING: IPv4 forwarding is disabled. Networking will not work. a73aab05adde4xxxxxxxxxxff205ba8a9262bcb6759fda787e30764b6a32963e
解決辦法: 在宿主機(就是Docker所在的操做系統)上操做web
修改 /usr/lib/sysctl.d/00-system.conf 文件,在結尾添加 net.ipv4.ip_forward=1
,docker
[root[@xxxxxx](https://my.oschina.net/xxww) ~]# vim /usr/lib/sysctl.d/00-system.conf # Kernel sysctl configuration file # # For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and # sysctl.conf(5) for more details. # Disable netfilter on bridges. net.bridge.bridge-nf-call-ip6tables = 0 net.bridge.bridge-nf-call-iptables = 0 net.bridge.bridge-nf-call-arptables = 0 net.ipv4.ip_forward=1
而後重啓 networkvim
[root[@xxxxxx](https://my.oschina.net/xxww) ~]# systemctl restart network
再執行啓動容器就能夠了app
[root[@bogon](https://my.oschina.net/u/3914826) sysctl.d]# docker run -d -P training/webapp python app.py 5b5783abf0a2xxxxxxxxxx5ec5f79099415ad46e18122aa120852d47958b5eb7
參考文檔:Locutuswebapp