8 Supporting reliability with health checks and dependency checks
We’re on a journey toward making software production-ready in containers. You’ve already seen how straightforward it is to package apps in Docker images, run them in containers, and define multi-container apps with Docker Compose. In production, you’ll run your apps in a container platform like Kubernetes, and those platforms have features that help you deploy self-healing apps. You can package your containers with information the platform uses to check whether the application inside the container is healthy. If the app stops working correctly, the platform can remove a malfunctioning container and replace it with a new one.
In this chapter, you’ll learn how to package those checks into your container images to help the platform keep your app online.
8.1 Building health checks into Docker images
Docker monitors the health of your app at a basic level every time you run a container. Containers run a specific process when they start, which could be the Java or .NET runtime, a shell script, or an application binary. Docker checks that the process is still running, and if it stops, the container goes into the exited state.