Home / Companies / Couchbase / Blog / Post Details
Content Deep Dive

Using the Docker Healthcheck Command

Blog post from Couchbase

Post Details
Company
Date Published
Author
Arun Gupta, VP, Developer Advocacy, Couchbase
Word Count
834
Language
English
Hacker News Points
-
Summary

Docker 1.12 introduced a new feature allowing health checks to be integrated into the container's image definition, which can also be overridden via the command line. This feature is crucial as it provides a method for the application inside the container to report its health status, rather than just indicating whether the container is up. The Dockerfile for the arungupta/couchbase image includes a health check instruction that verifies the health of the container by executing a command that checks the availability of a Couchbase REST API endpoint every 5 seconds, with a timeout of 3 seconds. If the health check command fails, the container's status is marked as unhealthy, and Docker's exit status reflects this, with 0 indicating a healthy container and 1 indicating an unhealthy one. Users can also specify health check commands at runtime using the docker run command if the image does not include a HEALTHCHECK instruction. This feature enhances container management by allowing users to monitor the health status of their applications more effectively.