Google News
logo
Docker - Interview Questions
Why do my services take 10 seconds to recreate or stop?
A docker-compose stop will attempt to stop a specific Docker container by sending a SIGTERM message. Once this message is delivered, it waits for the default timeout period of 10 seconds and once the timeout period is crossed, it then sends out a SIGKILL message to the container – in order to kill it forcefully. If you are actually waiting for the timeout period, then it means that the containers are not shutting down on receiving SIGTERM signals/messages.
 
In an attempt to solve this issue, the following is what you can do :
 
* You can ensure that you are using the JSON form of the CMD and also the ENTRYPOINT in your docker file.
* Use [“program”, “argument1”, “argument2”] instead of sending it as a plain string as like this – “program argument1 argument2”.
* Using the string form, makes Docker run the process using a bash that can’t handle signals properly. Compose always uses the JSON form.
* If it is possible then modify the application which you intend to run by adding an explicit signal handler for the SIGTERM signal
* Also, set the stop_signal to a proper signal that the application can understand and also know how to handle it.
Advertisement