Closed rayrapetyan closed 1 year ago
I think this means your process doesn't have a handler for SIGUSR2
registered; from signal(7)
(https://manpages.debian.org/bullseye/manpages/signal.7.en.html#Standard_signals), SIGUSR2
is a terminating signal by default.
Hm, I didn't know SIGUSRs are terminating by default, that's why used a random web server as example, sorry. But initially this issue happened with my own image which has a SIGUSR2 handler. I've created a POC repo: https://github.com/rayrapetyan/test_sig.
Steps to reproduce the issue:
PID of this script: 433226
Running....
Running....
...
kill -SIGUSR2 433226
handling SIGUSR2
Running....
and process continues running as expected.
Now run cmd.sh from container:
docker build -t test_sig:latest .
docker run --rm --init --name test_sig test_sig:latest
Send SIGUSR2:
docker kill --signal SIGUSR2 test_sig
Expected: cmd.sh running inside a docker container should receive and handle a signal and continue running. Actual: container stops.
Now after looking into how cmd.sh is running inside a container:
/sbin/docker-init -- /bin/sh -c ./cmd.sh -> bash cmd.sh
I realize that because of /bin/sh is running before bash, it's intercepting all signals and doesn't forward them to a child processes (bash) properly?
Works when running as:
docker run --rm --init --name test_sig test_sig:latest ./cmd.sh
so no /bin/sh in between.
Description This looks like invalid behavior: docker-init (tini) process should proxy signals to child processes. Instead any container started with --init flag can be killed with a non-terminal signal (e.g. SIGUSR2, SIGHUP etc).
Reproduce
Expected behavior Container continues to run (as it does when started without --init flag)
Actual Container is being stopped and killed
docker version
docker info