Apache with Docker Alpine Linux
It is true that Apache uses SIGWINCH to trigger a graceful shutdown:
docker kill ----signal=SIGWINCH apache
docker-library/httpd issue 9 mentions
Even just dropping "
-t
" should remove the sending ofSIGWINCH
when the window resizes.
Actually, you need just -d
: see PR669.
In your case, you already running the image with -dit
, so check if just keeping -d
might help.
The original issue (on httpd side, not docker) is described in bug id 1212224.
The OP Sebi2020 confirms in the comments:
if I don't connect a tty the signal isn't send
So if possible, avoid the -t
and, if needed, add a docker exec -t
session if you need tty.
You could try switching your CMD
instruction from exec form
to shell form
which leads to /bin/sh -c <...>
being used when the container is run:
CMD /usr/sbin/httpd -f /etc/apache2/httpd.conf -DFOREGROUND # or use ENTRYPOINT with the same shell form
It then no longer has PID 1 and Unix signals are not passed down to subprocesses.
But I am not sure (depending on your workflow) if you can attach
or exec -it
to or stop
the container as you would like to.
References:
http://www.johnzaccone.io/entrypoint-vs-cmd-back-to-basics/
(Fact 3)
https://docs.docker.com/engine/reference/builder/#cmdhttps://docs.docker.com/engine/reference/builder/#shell-form-entrypoint-example