第一次启动还正常呢,第二次启动就不可以了。
[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所在的操作系统)上操作
修改 /usr/lib/sysctl.d/00-system.conf 文件,在结尾添加
net.ipv4.ip_forward=1
,[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
然后重启 network
[root[@xxxxxx](https://my.oschina.net/xxww) ~]# systemctl restart network
再执行启动容器就可以了
[root[@bogon](https://my.oschina.net/u/3914826) sysctl.d]# docker run -d -P training/webapp python app.py
5b5783abf0a2xxxxxxxxxx5ec5f79099415ad46e18122aa120852d47958b5eb7
参考文档:Locutus