Docker Compose Dev, Debugging, CI, and Production Patterns/App with healthcheck and restart policy

Adds self-healing and health visibility to a service.

Section: Production-Minded Compose Patterns

App with healthcheck and restart policy

yaml
yaml
services:
  app:
    image: myapp:${APP_TAG:-latest}
    restart: unless-stopped
    healthcheck:
      test: ["CMD-SHELL", "curl -fsS http://localhost:3000/health || exit 1"]
      interval: 30s
      timeout: 5s
      retries: 3
Explanation

Useful for small-host production deployments and uptime monitoring.

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 Production-Minded Compose Patterns
Proxy + app pattern
Basic reverse-proxy plus app service pattern.
OpenIn sheetyamlsame section
Backup sidecar pattern
Defines an operational backup task as a profile-gated service.
OpenIn sheetyamlsame section
Watch files and sync/rebuild
Watches project files and applies sync or rebuild actions when configured.
OpenIn sheetbash2 tag match
Validate effective config
Checks whether the Compose config is valid without printing it.
OpenIn sheetbash2 tag match
Build stack in CI
Builds the project with CI-specific overrides applied.
OpenIn sheetbash2 tag match
Run test suite in service
Runs tests in a disposable service container.
OpenIn sheetbash2 tag match