ouzdev
ouzdev

Reputation: 67

It takes too long to shut down the Docker container

I set up Docker on Windows Server 2019. When I want to turn off containers, I have to wait too long on the console screen.

enter image description here

When I type and run a shutdown command, it stays that way for a long time, as shown in the picture.

I wonder what this problem might be about. Thank you for your help in advance.

Upvotes: 6

Views: 11704

Answers (2)

Sahadat Hossain
Sahadat Hossain

Reputation: 4379

When you use docker stop command docker container stop <container_name> and you can also pass the number of seconds before a container is killed by a --time flag.

Ex: docker container stop <container_name> -t 1: The command will wait 1 second as we gave the -t 1 before the killing.

The default number of seconds the docker container stop <container_name> command will wait before the killing is 10 seconds.

Upvotes: 4

Krishna Chaurasia
Krishna Chaurasia

Reputation: 9590

From the docs, when you execute the command docker container stop:

The main process inside the container will receive SIGTERM, and after a grace period, SIGKILL.

The command also supports an optional flag -t which you can use to change the default grace period to reduce the time to send the SIGKILL signal. The default value is 10 seconds.

However, you should use this option carefully depending on the application running in the container as the application can get into unexpected state if it doesn't handle forceful termination carefully.

Optionally, you can also use docker kill command to directly send the SIGKILL signal if you want to terminate the container forcefully.

Upvotes: 11

Related Questions