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

An article to understand operators in ECMAScript

Table of contents Unary Operators Boolean Operato...

Installation and configuration of mysql 8.0.15 under Centos7

This article shares with you the installation and...

Detailed explanation of various types of image formats such as JPG, GIF and PNG

Everyone knows that images on web pages are genera...

MySQL 5.7.18 Installer installation download graphic tutorial

This article records the detailed installation tu...

MySQL free installation version configuration tutorial

This article shares the MySQL free installation c...

Solve the problem of inconsistency between mysql time and system time in docker

Recently, when I installed MySQL in Docker, I fou...

Detailed example of Linux all-round system monitoring tool dstat

All-round system monitoring tool dstat dstat is a...

A simple example of using Vue3 routing VueRouter4

routing vue-router4 keeps most of the API unchang...

js to achieve the effect of dragging the slider

This article shares the specific code of how to d...

JavaScript counts the number of times a character appears

This article example shares the specific code of ...

Practice of using SuperMap in Vue

Table of contents Preface Related Materials Vue p...