Home  >  Article  >  Operation and Maintenance  >  What should I do if docker cannot connect to the web page?

What should I do if docker cannot connect to the web page?

coldplay.xixi
coldplay.xixiOriginal
2020-06-12 14:08:183243browse

What should I do if docker cannot connect to the web page?

What should I do if docker cannot connect to the web page?

Solutions to the problem that Docker cannot connect to the web page:

6 solutions to the problem that the Docker container cannot connect to the Internet

Note: The following The method is to be able to ping the public IP in the container. If the public IP cannot be pinged, the host may not be able to access the Internet (try ping 8.8.8.8)

1. Use --net:host option

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

2. Use --dns option

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

3.Change dns server

vi /etc/default/docker
Remove the # before "docker_OPTS="--dns 8.8.8.8 --dns 8.8.4.4""

##4. No need for dnsmasq

vi /etc/NetworkManager/NetworkManager.conf

Add a # sign before dns=dnsmasq and comment out

sudo restart network-manager

sudo restart docker

5. Rebuild docker0 network

pkill docker

iptables -t nat -F
ifconfig docker0 down
brctl delbr docker0
docker -d

6. Modify /etc/hosts directly in docker

Docker installation application (CentOS 6.5_x64):

http://www.linuxidc.com/Linux/2014-07/104595.htm

Using MySQL in Docker:

http://www.linuxidc.com/Linux /2014-01/95354.htm

Install Docker on Ubuntu Trusty 14.04 (LTS) (64-bit):

http://www.linuxidc.com/Linux/2014-10 /108184.htm

Docker installation application (CentOS 6.5_x64):

http://www.linuxidc.com/Linux/2014-07/104595.htm

Ubuntu 14.04 Install Docker:

http://www.linuxidc.com/linux/2014-08/105656.htm

Install Docker on Alibaba Cloud CentOS 6.5 template:

http://www.linuxidc.com/Linux/2014-11/109107.htm

Recommended tutorial: "

docker video tutorial"

The above is the detailed content of What should I do if docker cannot connect to the web page?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn