docker icon indicating copy to clipboard operation
docker copied to clipboard

cron.sh doesn't stop without SIGKILL

Open uumas opened this issue 2 months ago • 1 comments

The cron.sh script doesn't stop with the default SIGWINCH signal (or SIGTERM), which causes docker stop to wait for 10 seconds and fail over to SIGKILL. To reproduce:

docker run --name nextcloud-cron --rm --entrypoint /cron.sh docker.io/library/nextcloud
docker stop nextcloud-cron # Takes 10 seconds to complete

Docker hides this by silently falling back to SIGKILL, but it makes stopping take an unnecessary 10 seconds. If using podman, podman stop nextcloud-cron returns

WARN[0010] StopSignal SIGWINCH failed to stop container nextcloud-cron in 10 seconds, resorting to SIGKILL

uumas avatar Oct 20 '25 17:10 uumas

This may be the result of upstream base image handling (the php image) for the Dockerfile STOPSIGNAL. I believe the default was changed there to SIGWINCH a long time ago because Apache likes that for gracefully shutting down.

On the other hand, it looks like busybox crond prefers SIGTERM to do a graceful shutdown.

Not at my desk at the moment, but should be easy to test with either...

For an already running cron container:

docker kill -s TERM (possible "SIGTERM" not sure offhand)

Or by overriding the default STOPSIGNAL for when running the cron container:

docker run -stop-signal [...]

Since keeping it for Apache is desirable and we don't use separate Dockerfiles for Cron, not sure how to best handle this on a permanent basis at the moment... 🤔

joshtrichards avatar Oct 22 '25 19:10 joshtrichards