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 to do if the docker container hangs up?

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

Share

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

This article focuses on "how to deal with the hanging of docker containers". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to deal with the hang-up of docker containers.

There is nothing you can do but to restart the docker container after it hangs up, but to ensure that the service will not die, it is recommended to run it in the form of service, that is, in the swarm cluster, make a service highly available, and then use nginx or haproxy to load balancer. When a container hangs, you can use several other sites, and then the dead container will be re-run by service.

Need to do a monitoring, sometimes the site is dead, the container is not dead, the service will not restart, then rely on monitoring to make a logical judgment, run the script, stop container, let the service automatically run a new container. It is best to customize the image of a container with a site so that when the container is running, the site also runs.

Command to restart a dead docker container

Docker restart $(docker ps-a-Q)

If the docker daemon on a server is down, docker will distinguish the container process when the docker daemon starts. If the process is still there, that is, running, its kill will be adjusted.

According to the technical staff's understanding of the docker source code, docker does not trust other processes to manage it. It must manage these containers itself, and it is the parent process of all containers. This has a lot of benefits. The biggest benefit is real-time monitoring. Once the container is dead, it can immediately know and restart (if the container is set to restart=always).

Of course, if set to restart=always, the container will be started automatically when daemon starts. But if the container process is still there, the docker process will still be a kill drop process, and then start a new container process. To ensure that all container processes are still children of daemon.

At this point, I believe you have a deeper understanding of "how to deal with the hanging of docker containers". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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