| 1. |
Why Do My Services Take 10 Seconds To Recreate Or Stop? |
|
Answer» Compose stop attempts to stop a container by sending a SIGTERM. It then waits for a default timeout of 10 seconds. After the timeout, a SIGKILL is sent to the container to forcefully KILL it. If you are waiting for this timeout, it means that your containers aren’t shutting down when they receive the SIGTERM signal. There has already been a lot written about this problem of processes handling signals in containers. To fix this problem, try the following: Make SURE you’re using the JSON FORM of CMD and ENTRYPOINT in your Dockerfile. For example: use ["program", "arg1", "arg2"] not"program arg1 arg2". Using the string form causes Docker to run your process using bash which doesn’t handle signals properly. Compose always uses the JSON form, so don’t worry if you override the command or entrypoint in your Compose file.
Compose stop attempts to stop a container by sending a SIGTERM. It then waits for a default timeout of 10 seconds. After the timeout, a SIGKILL is sent to the container to forcefully kill it. If you are waiting for this timeout, it means that your containers aren’t shutting down when they receive the SIGTERM signal. There has already been a lot written about this problem of processes handling signals in containers. To fix this problem, try the following: Make sure you’re using the JSON form of CMD and ENTRYPOINT in your Dockerfile. For example: use ["program", "arg1", "arg2"] not"program arg1 arg2". Using the string form causes Docker to run your process using bash which doesn’t handle signals properly. Compose always uses the JSON form, so don’t worry if you override the command or entrypoint in your Compose file. |
|