Implement graceful shutdown for Docker executor
Overview
At the moment the Docker executor simply sends a kill to the Docker container and it's processed in here and don't provide any graceful termination we have something implemented like this in the custom executor and shell executor which to problems of containers living forever and other set of problems that we have no controll over.
Proposal
When terminating containers we are sometimes just calling removeContainer
& killContainer
but we don't allow for graceful shutdown, that is why first we should Call ContainerStop
instead of killContaienr
and also call containerStop
before we remove the container, after a specific timeout we will then send a KILL to the container. With this we allow processes to terminate properly and gracefully.
The technical details might get outdated very fast but we need to basically send SIGTERM
and then after x amount of time we send SIGKILL
if the process is still around.