1、docker端口映射到宿主機後外網沒法訪問(防火牆已關閉)
解決方法:mysql
#啓用IP路由轉發功能: [root@localhost ~]# echo 1 > /proc/sys/net/ipv4/ip_forward 或者 [root@localhost ~]# sysctl -w net.ipv4.ip_forward=1 #以上兩種方法均可能當即開啓路由功能,但若是系統重啓,或重啓網卡所設置的值即會丟失。 #若是想永久保留配置,能夠修改/etc/sysctl.conf文件 [root@localhost ~]# vi /etc/sysctl.conf 或者 [root@localhost ~]# vi /usr/lib/sysctl.d/00-system.conf 添加以下代碼: net.ipv4.ip_forward=1 從新加載系統參數 [root@localhost ~]# sysctl -p 查看是否修改爲功 [root@localhost ~]# sysctl net.ipv4.ip_forward 若是返回爲「net.ipv4.ip_forward = 1」則表示成功了
2、 windows宿主機沒法ping通vmware中安裝的docker
截圖爲vmware中ip地址,centos7虛擬機(192.168.110.128),docker網段(10.10.100.0)
現象:linux
解決方法:
手動在windows宿主機上添加一條路由策略web
route add 10.10.100.0 MASK 255.255.255.0 192.168.110.128
3、 Error response from daemon: driver failed programming external connectivity on endpoint pensive_panini
現象:sql
[root@bogon ~]# sudo docker run -d --restart=always -p 80:80 rancher/server 9d918ae01d60dc5ad749f98cc93fc144231051c7f8ab7a32d873ab6b3157fd38 docker: Error response from daemon: driver failed programming external connectivity on endpoint pensive_panini (fb0be019dff5a5824452718fa556c5d8264e76a2addacadbaf1b8fc23cae2855): (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 80 -j DNAT --to-destination 10.10.100.2:80 ! -i docker0: iptables: No chain/target/match by that name. (exit status 1)).
解決方法:docker
[root@bogon ~]# systemctl restart docker [root@bogon ~]# docker container restart 9d918
4、centos7解決 docker Failed to get D-Bus connection 報錯
在docker容器裏面安裝mysql數據庫,如下爲安裝mysql的命令:數據庫
yum -y install mariadb* systemctl start mariadb.service # 運行到這條報錯 systemctl enable mariadb.service
解決方法:
這個的緣由是由於dbus-daemon沒能啓動。其實systemctl並非不可使用。在CentOS7中的安全模塊selinux把權限禁掉了,參數給容器加特權,不加上傳鏡像會報相似權限錯誤。OSError: [Errno 13] Permission denied: ‘/tmp/registry/repositories/liibrary’)或者(Received unexpected HTTP status: 500 Internal Server Error)
將你的CMD或者entrypoint設置爲/usr/sbin/init便可。會自動將dbus等服務啓動起來。 而後就可使用systemctl了。命令以下:windows
#在建立docker容器時添加--privileged docker run --privileged -tid --name "webserver" --mount source=my-vol,target=/webapp training/webapp /usr/sbin/init