How to solve the problem of domain name resolution failure in docker container

王林
Release: 2020-04-14 10:56:19
Original
5355 people have browsed it

How to solve the problem of domain name resolution failure in docker container

Cause:

Linux system does not turn on the IP forwarding function by default.

Solution:

Just turn on the IP forwarding function.

Solution:

1. Confirm the status of the IP forwarding function

Use the following command to view the /proc file system,

cat /proc/sys/net/ipv4/ip_forward012
Copy after login

If the value in the above file is 0, it means that IP forwarding is prohibited; if it is 1, it means that the IP forwarding function has been turned on.

2. If you want to turn on the IP forwarding function, you can directly modify the above file:

echo 1 > /proc/sys/net/ipv4/ip_forward1
Copy after login

Change the content of the file from 0 to 1. Disabling IP forwarding changes 1 to 0.

3. The above command does not save the changes to the IP forwarding configuration. The original value will still be used the next time the system starts. To permanently modify the IP forwarding, you need to modify the /etc/sysctl.conf file. Modify the value of the following line:

net.ipv4.ip_forward = 11
Copy after login

4. After modification, you can restart the system to make the modification effective, or execute the following command to make the modification effective

sysctl -p /etc/sysctl.conf1
Copy after login

After the above configuration, IP The forwarding function is permanently enabled.

Note: centos7 operates the /usr/lib/sysctl.d/50-default.conf file

Recommended tutorial: docker tutorial

The above is the detailed content of How to solve the problem of domain name resolution failure in docker container. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template