首頁  >  文章  >  運維  >  docker連不上網頁怎麼辦?

docker連不上網頁怎麼辦?

coldplay.xixi
coldplay.xixi原創
2020-06-12 14:08:183369瀏覽

docker連不上網頁怎麼辦?

docker連不上網頁怎麼辦?

docker連不上網頁的解決方法:

Docker容器內不能連網的6種解決方案

註:下面的方法是在容器內能ping通公網IP的解決方案,如果連公網IP都ping不通,那主機可能也上不了網(嘗試ping 8.8.8.8)

1.使用--net:host選項

sudo docker run --net:host --name Ubuntu_bash -i -t ubuntu:latest /bin/bash

#2.使用--dns選項

sudo docker run --dns 8.8.8.8 --dns 8.8.4.4 --name ubuntu_bash -i -t ubuntu:latest /bin/bash








################################################ # ##3.改dns server#########vi /etc/default/docker###去掉「docker_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"」前的#編號# ########4.不用dnsmasq#########vi /etc/NetworkManager/NetworkManager.conf###在dns=dnsmasq前面加個#號註解掉###### sudo restart network-manager###sudo restart docker#########5.重建docker0網路#########pkill docker###iptables -t nat -F###ifconfig docker0 downdown ###brctl delbr docker0###docker -d#########6.直接在docker內修改/etc/hosts#########Docker安裝應用(CentOS 6.5_x64):# ##http://www.linuxidc.com/Linux/2014-07/104595.htm#########在Docker 中使用 MySQL:###http://www.linuxidc.com/Linux /2014-01/95354.htm#########在Ubuntu Trusty 14.04 (LTS) (64-bit)安裝Docker:###http://www.linuxidc.com/Linux/2014-10 /108184.htm#########Docker安裝應用程式(CentOS 6.5_x64):###http://www.linuxidc.com/Linux/2014-07/104595.htm####### ###Ubuntu 14.04安裝Docker :###http://www.linuxidc.com/linux/2014-08/105656.htm##########阿里雲CentOS 6.5 範本上安裝Docker:## #http://www.linuxidc.com/Linux/2014-11/109107.htm#########推薦教學:《###docker影片教學###》###

以上是docker連不上網頁怎麼辦?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn