5 Docker Compose tricks that made my home server more reliable
This was an interesting article. I did not know about the limiting of restarts up to a defined number of failures. That is pretty useful to prevent a container continuously restating, and then sometimes showing as green for running.
The other intriguing one was using curl for health checks. Just note you must use the internal container port as it is running inside the container. If curl is not present in your container, the wget command can be used instead.
The syntax for both, that I found worked, were:
test: ["CMD-SHELL", "curl -f
http://localhost:8080 || exit 1"] and
test: ["CMD-SHELL", "wget -q --spider
http://localhost:8080 || exit 1"] so I hope that helps others.
Another trick, where some containers only respond when using the container IP address (which changes) is to use something like this for the IP and port:
http://$(hostname -i):8080.
I had one stubborn container, a MQTT one, that refused to respond to any querying, so I used this instead test: ["CMD-SHELL", "pgrep mosquitto || exit 1"] which checks if the process is running inside the container.
See
5 Docker Compose tricks that made my home server more reliable
A collection of tips and tricks that leveled up my Docker Compose game
#
technology #
docker #
containers #
selfhosting