Solution to docker suddenly not being accessible from the external network

Solution to docker suddenly not being accessible from the external network

According to the methods of the masters, the cause was found: sysctl net.ipv4.ip_forward. Tencent Cloud prompted to fix the vulnerability. After executing their script, IP forwarding was turned off.

After some research, I was able to find the problem through docker info.

And you can see that docker gives a warning

Solution:

sudo vim /etc/sysctl.conf Modify, save, then systemctl restart network

or

sysctl -w net.ipv4.ip_forward=1

But this treatment may become invalid after the server is restarted?

There are two more warnings, so let's deal with them together.

WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled

Supplement: Docker network problem, the external IP of the host machine cannot be pinged in the Docker container, but the external IP of other machines can be pinged

Problem Description

Machine A and machine B each have their own internal IP and external IP, for example: A-IP-internal, A-IP-external

B-IP-inside, B-IP-outside, machine A has a domain name www.xxx.com

Install the Jenkins Docker container on machine A, start it, and enter the container

#docker exec -it jenkins /bin/sh
Then ping the internal IP of host A in the container, and it can be pinged#ping A-IP-internal (172.16...) //Returns that it can be pinged#ping A-IP-external (202.106...) //Failed to ping#ping www.xxx.com //Can be correctly resolved to the external IP of machine A, but ping cannot be pinged#ping baidu.com //Can be pinged

in addition:

1. From the host machine A outside the docker container, ping A-IP-outside (202.106...) is successful.

2. Install the Jenkins container on machine B, and ping A-IP-external (202.106...) from within the container.

2. Install the Jenkins container on machine B. Pinging B-IP-external (202.106…) from within the container is unsuccessful.

Looking for various network problems, deleting containers, images, and reinstalling docker all do not work.

In short: How can I ping the public IP of the host machine itself in the docker container?

I need to ping www.xxx.com in the container of machine A, which will be resolved to the intranet address of machine A.

Because the intranet address of machine A can be pinged from within the container.

New modified docker-compose file

extra_hosts:
- "www.xxx.com:172.16.xxx.A"

After rebuilding the docker container, enter the docker container

#ping A-IP-outside (202.106...) // Pinged successfully, OK meets the requirement

The above is my personal experience. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. If there are any mistakes or incomplete considerations, please feel free to correct me.

You may also be interested in:
  • Docker container accesses the host's MySQL operation
  • Docker container custom hosts network access operation
  • Docker port mapping and external inaccessibility issues
  • How to enable remote access in Docker
  • Solution to the problem that Docker container cannot access Jupyter
  • 404 error occurs when accessing the homepage of tomcat started in Docker mode
  • Docker image access to local elasticsearch port operation

<<:  MySQL performance optimization index pushdown

>>:  Vue implements simple comment function

Recommend

MySQL query statement grouped by time

MySQL query by year, month, week, day group 1. Qu...

CSS to implement QQ browser functions

Code Knowledge Points 1. Combine fullpage.js to a...

mysql three tables connected to create a view

Three tables are connected. Field a of table A co...

How to delete the container created in Docker

How to delete the container created in Docker 1. ...

Example of MySQL slow query

Introduction By enabling the slow query log, MySQ...

How to install Zookeeper service on Linux system

1. Create the /usr/local/services/zookeeper folde...

React antd tabs switching causes repeated refresh of subcomponents

describe: When the Tabs component switches back a...

Example of using store in vue3 to record scroll position

Table of contents Overall Effect Listen for conta...

Install multiple versions of PHP for Nginx on Linux

When we install and configure the server LNPM env...

How to count down the date using bash

Need to know how many days there are before an im...

Share 5 JS high-order functions

Table of contents 1. Introduction 2. Recursion 3....

How to modify the default storage location of Docker images (solution)

Due to the initial partitioning of the system, th...

Springboot+Vue-Cropper realizes the effect of avatar cutting and uploading

Use the Vue-Cropper component to upload avatars. ...

Reasons and solutions for failure to insert emoji expressions in MySQL

Failure Scenario When calling JDBC to insert emoj...

Html+css to achieve pure text and buttons with icons

This article summarizes the implementation method...