Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the reason why docker is slow to enter the container?

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "what is the reason why docker enters the container very slowly". In daily operation, I believe many people have doubts about what is the reason why docker enters the container very slowly. Xiaobian consulted all kinds of materials and sorted out simple and easy operation methods. I hope to help you answer the question of "what is the reason why docker enters the container very slowly"! Next, please follow the small series to learn together!

The host OS distribution you are using is likely to differ from the distribution of the base image in the container. Local distribution software sources tend to be domestic, while official mirror sources tend to be foreign.

Connecting to foreign sources is likely to be very slow due to domestic networks. Therefore, if foreign sources are used in the base image in the container, apt-get update will be very slow when the container runs domestically.

One more thing to note: DNS issues with containers. Once you run docker daemon or docker run without specifying dns, and the default dns of the host is 127.0.0.1, docker daemon will automatically configure the container with dns of 8.8.4.4 and 8.8.8.8, and these two DNS addresses are not very stable when used in China. Therefore, there are also cases where domain name resolution is slow or even blocked.

Fix slow network requests in docker container

After packet capture test and other analysis, it is found that network requests are slow, mainly occurring in DNS resolution, so DNS optimization is mainly adopted.

If the request is your own intranet api, you can directly modify the/etc/hosts file. If it is an external network request, you can change the nameserver in/etc/resolv.conf.

Docker containers are definitely not implemented directly by modifying files, but can be implemented by the run command:

#Add hostdocker run --name app --add-host='api.embbnux.com:10.98.10.98' -d ubuntu#Specify dns serverdocker run --name app --dns=223.5.5.5 --dns= 8.8.8-d ubuntu

This speeds up the dns parsing phase in the docker container

At this point, the study of "what is the reason why docker enters the container slowly" is over, hoping to solve everyone's doubts. Theory and practice can better match to help everyone learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report