Docker Healthcheck Generator
Generate robust Dockerfile HEALTHCHECK and docker-compose health probes with presets for Node, Postgres, Redis, and MySQL — entirely in your browser.
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \ CMD curl -f http://localhost:8080/health || exit 1
healthcheck: test: ["CMD-SHELL", "curl -f http://localhost:8080/health || exit 1"] interval: 30s timeout: 5s retries: 3 start_period: 5s
- Ensure the binary (e.g. curl or wget) is installed in your minimal runtime image (e.g. Alpine/Debian slim).
- Set an appropriate --start-period so the container is not prematurely flagged unhealthy during cold boot or migrations.
- Keep timeouts short (3-5s) so frozen containers don't unnecessarily hold up traffic routing.
Do it offline:$
How to use it
- Select your target service preset (REST API / Web curl, wget, pg_isready, redis-cli, or custom command).
- Configure healthcheck timings: interval between checks, timeout, start period initialization window, and retry attempts.
- Inspect the generated Dockerfile HEALTHCHECK line and docker-compose.yaml healthcheck block.
- Copy the snippet directly into your container definition to enable proactive container orchestration self-healing.
Generate production-ready HEALTHCHECK directives for Dockerfiles and docker-compose.yaml with service presets for Node, Python, Postgres, Redis, and MySQL.
How it works
The Docker daemon and Docker Compose invoke the specified healthcheck command inside the running container at the configured interval.
The command must return exit code 0 if healthy, or exit code 1 if unhealthy. Non-zero exit codes trigger retries until the container is marked unhealthy.
Modern orchestrators like Docker Swarm and Kubernetes rely on container health statuses to manage traffic routing and automated pod/container restarts.
This generator generates syntactically validated instructions directly in your browser with zero data sent to external servers.
Examples
Every example on this page is executed against the same engine that powers the tool, on every build.
Gotchas worth knowing
Common errors
FAQ
What is the importance of the --start-period parameter?
The start period provides container workloads initialization time (such as database migrations or JVM warm-up). Probe failures during the start period do not count towards the retry limit, preventing premature container restarts.
Why should I use wget or curl with specific flags in health checks?
Using curl with -f ensures non-2xx/3xx HTTP error statuses return a non-zero exit code. In wget, using --spider prevents downloading files to disk, saving container I/O and disk overhead.
Can I use HEALTHCHECK with distroless container images?
Distroless images lack shells and standard tools like curl. For distroless, consider compiling a tiny health probe binary written in Go/Rust or performing the health check at the orchestrator layer (such as Kubernetes exec or HTTPGet probes).