getgrav / docker-grav

Official Docker Image for Grav
https://getgrav.org
197 stars 123 forks source link

Container does not stop gracefully #60

Closed kman1999 closed 5 months ago

kman1999 commented 5 months ago

The container image built by the Dockerfile in this repo results in a container that cannot be stopped gracefully (i.e. doesn't respond to SIGWINCH like the base apache-php image does).

Root cause: The CMD in the Dockerfile is not correctly launching apache2 as PID 1, so the stop signals never reach the apache2 process.

Fix: Change the final line in the Dockerfile to be: CMD ["sh", "-c", "cron && exec apache2-foreground"]

The "exec" is required so that apache2 replaces the shell as PID 1. It will then respond to SIGWINCH and gracefully stop.

For a better understanding of how to correctly deal with signals inside containers, see https://github.com/Yelp/dumb-init