6 solutions for network failure in Docker container

6 solutions for network failure in Docker container

6 solutions for network failure in Docker container

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

1. Use the –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 # sign 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 # before dns=dnsmasq to comment it out

sudo restart network-manager
sudo restart docker

5. Rebuild the docker0 network

pkill docker #Terminate the process iptables -t nat -F #Clear all chains in the nat table ifconfig docker0 down #Stop the docker default bridge brctl delbr docker0 #Delete the bridge docker -d

6. Modify /etc/hosts directly in docker

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links

You may also be interested in:
  • Example of how to create and run multiple MySQL containers in Docker
  • How to isolate users in docker containers
  • How to implement Docker container self-start
  • Detailed explanation of importing/exporting MySQL data in Docker container
  • Docker container uses Jenkins to deploy web projects (summary)
  • Method for accessing independent IP in Docker container
  • Detailed explanation of migrating local Docker containers to the server
  • How to use Mysql in Tomcat container under Docker
  • How to install and uninstall docker application container engine under Centos7
  • Add port mapping after docker container starts
  • Detailed explanation of Docker port mapping and container interconnection
  • Docker Tutorial: Using Containers (Simple Example)

<<:  JavaScript gets the scroll bar position and slides the page to the anchor point

>>:  Vue+Bootstrap realizes a simple student management system

Recommend

Pricing table implemented with CSS3

Result: Implementation Code html <div id="...

Discuss the value of Web standards from four aspects with a mind map

I have roughly listed some values ​​to stimulate ...

Docker Swarm from deployment to basic operations

About Docker Swarm Docker Swarm consists of two p...

Mysql join query syntax and examples

Connection query: It is the result of connecting ...

Mini Program Custom TabBar Component Encapsulation

This article example shares the specific code for...

Docker-compose one-click deployment of gitlab Chinese version method steps

1. Introduction to gitlab Gitlab official address...

jQuery to achieve the barrage effect case

This article shares the specific code of jQuery t...

How to solve the Mysql transaction operation failure

How to solve the Mysql transaction operation fail...

MySQL optimization tutorial: large paging query

Table of contents background LIMIT Optimization O...

How to install Mysql5.7 in Centos6

environment Centos 6.6 MySQL 5.7 Install If the s...

CentOS6.8 uses cmake to install MySQL5.7.18

Referring to the online information, I used cmake...

Detailed tutorial on installing ElasticSearch 6.x in docker

First, pull the image (or just create a container...

Some questions about hyperlinks

I am very happy to attend this episode of potato ...

Learn how to use the supervisor watchdog in 3 minutes

Software and hardware environment centos7.6.1810 ...

How to solve mysql error 10061

This article shares with you the solution to the ...