brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: docker kill --signal=HUP sends a reload signal instead of killing

Docker
~/tips/tip-docker-kill-signal-hup

docker kill --signal=HUP my-proxy

Sends any signal, such as HUP, to a container's main process without stopping the container.

The name is misleading. docker kill sends SIGKILL by default, but with --signal it is just a way to deliver any signal to a container’s main process, including the one many daemons treat as a request to reload their config.

The reference gives the options: -s or --signal takes a name with or without the SIG prefix, or a number, so SIGHUP, HUP and 1 are all the same.

docker kill --signal=HUP my-proxy

Whether that reloads anything is up to the program. Many servers re-read their configuration on SIGHUP and keep running, and the docs note that some signals do not stop the container, depending on the main process. Check the application’s own documentation for what it does with HUP before you rely on it.

It is nice for a proxy or a DNS server where you edited a mounted config file and do not want to drop connections with a full restart.

One catch comes straight from the docs: ENTRYPOINT and CMD in shell form run under /bin/sh -c, which does not pass signals along. In that case your app is not PID 1 and never receives the signal, and you will see nothing happen. Use the exec form (a JSON array) in the Dockerfile, or an image that already does. And without --signal, the command really does kill the container, so double check the name first.

Further reading: docker container kill

More Docker tips ONBUILD RUN /usr/local/bin/python-build --dir /app/src SHELL ["/bin/bash", "-c"] docker commit <container> myname/testimage:version3 docker import /path/to/exampleimage.tgz docker compose events All Docker tips (192) All topics

Link