HEALTHCHECK

The HEALTHCHECK instruction can be used to inform Docker how to test a container to check that it is still working. This can be checking if our rest service responds to HTTP calls or just listens on a specified port.

A container can have several statuses which can be listed using the docker ps command. These can be created, restarting, running, paused, exited, or dead. But sometimes this is not enough; a container may be still alive from Docker's point of view, but the application can hang or fail in some other way. An additional checking for the application status can be useful and HEALTHCHECK comes in handy.

The HEALTHCHECK status is initially starting. Whenever a health check passes, it becomes healthy (whatever state it was ...

Get Docker and Kubernetes for Java Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.