redlib icon indicating copy to clipboard operation
redlib copied to clipboard

🐛 Bug Report: Container does not stop using SIGTERM - Podman/Docker resorts to SIGKILL

Open msinfo32github opened this issue 1 year ago • 0 comments

Describe the bug

When using the Docker, or Podman container built either using this Dockerfile or the image at quay.io/redlib/redlib:latest, stopping the container using either podman stop redlib or docker stop redlib does not stop the container properly, and instead of using SIGTERM, the container stops using SIGKILL. This causes a 10 second delay in stopping the container.

Although not a large problem as Redlib does not store any data etc, this still delays container shutdown - e.g. added 10 second delay when shutting down a VM.

Steps to reproduce the bug

Pull container image from quay.io/redlib/redlib:latest or build from the Dockerfile

podman pull quay.io/redlib/redlib:latest

Run the container using Podman (same for Docker)

podman run --rm -d --name redlib -p 127.0.0.1:8080:8080 quay.io/redlib/redlib:latest

Stop the container

podman stop redlib

Warning from Podman (Docker does not give a warning, but there is still a 10s+ time stopping the container)

WARN[0010] StopSignal SIGTERM failed to stop container redlib in 10 seconds, resorting to SIGKILL 
redlib

What's the expected behavior?

Stopping the container using either podman stop redlib or docker stop redlib stopping quickly as it terminates PID 1 redlib properly with a SIGTERM to shut down the application instead of falling back on a SIGKILL.

Additional context / screenshot

This behaviour is seen using the Dockerfile in the root of this repository, the quay.io repository image as well as this Dockerfile seen at https://github.com/redlib-org/redlib/issues/122#issuecomment-2143727362

This could be worked around by either handling the SIGTERM in the redlib application itself, or by using a bash script to handle and pass a SIGKILL to the process received by the BASH script used as a container CMD - however this should not be the best setup as this could cause other problems by adding more complexity.

msinfo32github avatar Aug 20 '24 18:08 msinfo32github