Defines a readiness-style health check for the service.
Section: Dependencies and Healthchecks
Healthcheck on a service
yaml
yaml
services:
db:
image: postgres:16
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5Explanation
Useful for observability and dependency-aware startup.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Dependencies and Healthchecks
Wait for healthy dependency
Uses health state as the dependency condition for startup ordering.
Minimal web + db stack
Simple two-service stack with port publishing and environment variables.
Environment as key/value map
Provide container environment values inline in YAML.
Define optional profiles
Marks a service as optional unless its profile is enabled.
Service built from Dockerfile
Build a service image from local source while also tagging it.