Skip to main content

Docker HEALTHCHECK Generator

Generate Docker HEALTHCHECK instructions for your Dockerfile and docker-compose.yml. Choose HTTP, TCP port, shell command, or file-based checks — with configurable timing options.

✓ HTTP / TCP / CMD / File checks ✓ Dockerfile + docker-compose output ✓ Timing validation warnings

Frequently Asked Questions

What does Docker HEALTHCHECK do?▼

The HEALTHCHECK instruction tells Docker how to test if a container is working. Docker runs the health check command at the specified interval. If the command exits with 0, the container is 'healthy'. If it exits with 1, it is 'unhealthy'. The health status is visible in docker inspect and docker ps, and used by orchestrators like Kubernetes and Docker Swarm for routing decisions.

What is start-period and why is it important?▼

start-period gives your container a grace period after it starts before health check failures count toward the retries threshold. During start-period, failures are recorded but don't contribute to the failure count. This prevents containers from being marked unhealthy during a slow initialization (e.g., database startup, JVM warm-up). Set it longer than your worst-case startup time.

What tools can I use for HTTP health checks?▼

curl is the most common: curl -f URL exits with non-zero on HTTP errors (4xx/5xx). wget -q --spider URL is a lighter alternative. If curl isn't in your image, install it, or use CMD-SHELL with a language-specific alternative. For minimal images, consider adding a tiny health check binary like healthcheck.

How do I check health for databases?▼

PostgreSQL: pg_isready -U postgres. MySQL/MariaDB: mysqladmin ping -h localhost. Redis: redis-cli ping. MongoDB: mongosh --eval 'db.runCommand({ping:1})'. These are purpose-built health check commands that don't require opening a full connection and are fast and low-overhead.

What is the difference between Dockerfile HEALTHCHECK and docker-compose healthcheck?▼

The Dockerfile HEALTHCHECK is baked into the image — it applies whenever the image is run. docker-compose healthcheck overrides or supplements the image's HEALTHCHECK for a specific service in a Compose setup. You can use depends_on with condition: service_healthy to wait for a service to be healthy before starting a dependent service.

What happens when a container becomes unhealthy?▼

Docker marks the container as 'unhealthy' in docker ps and docker inspect. The container keeps running — Docker does not automatically restart unhealthy containers. Orchestrators (Docker Swarm, Kubernetes) use health status to route traffic away from unhealthy containers and replace them. For Kubernetes, use readinessProbe and livenessProbe instead of Docker HEALTHCHECK.

Share this tool: X / Twitter LinkedIn
✓ 60,000+ developers use DevPlaybook ★★★★★ 4.8 / 5 on Gumroad ✓ MIT licensed · Instant download ✓ No login required

Related Products

on Gumroad

You Might Also Need

More Free Tools

Enjoying this tool? Get more like it.

Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.

DevPlaybook Pro 7 days free

Unlock AI-Powered Dev Tools

  • ⚡ AI Code Review, Doc Generator & SQL Builder
  • ⚡ All premium templates & early access
  • ⚡ Member discounts on Gumroad products
Start Free Trial →

$9/mo after trial · Cancel anytime

Want the full toolkit?

Get DevPlaybook Pro

Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.

$79
$241 separately Save $162 (67% off)
Get DevPlaybook Pro — $79 →

MIT licensed · Instant download · No subscription

See what's included → Browse all deals →