0
votes

We have Docker container which is running systemd as main process (PID 1). We have also started our worker processes in Docker container through systemd unit. Our Docker containers uses CentOS 7.2. We have configured the Docker stop timeout so that we can handle the graceful shutdown of worker processes running inside Docker container. When we are stopping Docker container, we can see SIGTERM is received to systemd process which is running with PID 1 inside container. Also container waits for stop timeout which we have configured. But systemd process is not forwarding this SIGTERM to our worker processes which we have started using systemd unit. From logs it looks like when systemd receives SIGTERM it tries to re-executes itself. We have tried with adding KillMode=mixed in our systemd unit file but it didn’t worked for us.

Is there any way to forward SIGTERM from systemd process to the child processes ?

2
From shared article it looks like regular system init (systemd in our case) should be able to forward SIGTERM to child processes but this is exactly not happens in our case. We want to use systemd for our setup. Looking for way to pass signals from systemd to child processes.Sachin

2 Answers

0
votes

Instead of running systemd itself you could also try with a replacement that provides a similar functionality. If you put the docker-systemctl-replacement as the entrypoint of the container then it will look for the systemd unit files you have provided - upon container start it runs ExecStart from unit descriptors and upon receiving SIGSTOP it will run ExecStop from each of the unit descriptors. It sounds like that's the functionality you want anyway.

-2
votes

Paste your docker run command, please.

I guess you have to add these 2 options.

--stop-signal=SIGRTMIN+3 --env container=docker