Search code examples
dockercontainerswindows-server-2019

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.


Solution

  • 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.