Home > Operation and Maintenance > Docker > How docker kills stuck containers

How docker kills stuck containers

Release: 2020-03-25 11:18:04
Original
7065 people have browsed it

How docker kills stuck containers

How docker kills the container:

docker stop

When we use the docker stop command to stop the container At this time, docker will allow the application in the container 10 seconds to terminate by default.

When the docker stop command is executed, it will first send the system signal SIGTERM to the process with PID 1 in the container, and then wait for the application in the container to terminate execution. If the waiting time reaches the set timeout, or The default 10 seconds will continue to send the SIGKILL system signal to forcefully kill the process.

docker kill

Then let’s take a look at the docker kill command. By default, the docker kill command will not give the application in the container any chance to gracefully shut down. . It will directly send the SIGKILL system signal to forcibly terminate the running of the program in the container.

For example, if we want to send a SIGINT signal to a program in docker, we can do it like this:

docker kill --signal=SIGINT container_name

with docker stop command The difference is that docker kill does not have any timeout setting. It will directly send the SIGKILL signal and other signals specified by the user through the signal parameter. Forcefully terminate the process.

Therefore, docker kill is suitable for forcibly terminating the program and quickly stopping the container. And if you want the program to shut down gracefully, docker stop is the best choice.

For more related tutorials, please pay attention to the docker tutorial column on the PHP Chinese website.

The above is the detailed content of How docker kills stuck containers. 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