So I’ve been working with a containerized solution recently which runs outside of
Kuberenetes using an Azure VMSS to scale out. I won’t dive into the reasons why we went down this route but one really interesting thing came of out of it.
How do you automatically healthcheck a container outside of Kubernetes?
Well it turns out
docker has this covered in newer versions. You can specify a
HEALTHCHECK inside the docker file to monitor the containers state
How do you ensure it restarts when unhealthy?
Well here you have a couple of options but both rely on using
--restart=always when starting the container:
- You `healthcheck` command runs inside the container so you can have it kill the root process of the container causing the container to restart – Example: https://github.com/opencb/opencga/pull/1121/files
- You can use `AutoHeal` container which monitors the docker deamon via it’s socket and handles and containers which report unhealthy https://hub.docker.com/r/willfarrell/autoheal/
Note: I’m trying a new format for shorter slightly rougher blog posts covering specific topics quickly. They’ll appear under
Quick-posttags. Please excuse typos and grammar issues!