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: 5
Explanation

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.
OpenIn sheetyamlsame section
Simple service dependency
Starts `db` before `web` in dependency order.
OpenIn sheetyamlsame section
Minimal web + db stack
Simple two-service stack with port publishing and environment variables.
OpenIn sheetyaml2 tag match
Environment as key/value map
Provide container environment values inline in YAML.
OpenIn sheetyaml2 tag match
Define optional profiles
Marks a service as optional unless its profile is enabled.
OpenIn sheetyaml2 tag match
Service built from Dockerfile
Build a service image from local source while also tagging it.
OpenIn sheetyaml2 tag match