← All examples
Containers
Docker ComposeDocker

Run a Docker Compose stack with a health gate

You want Runyard to start your backend stack via docker compose up, mark it as running only once your API responds, and properly shut everything down when you click Stop.

The trick

Two gotchas trip people up.

  1. Two CLIs, same name. docker compose (the V2 plugin, two words) is the current syntax. The standalone docker-compose binary (hyphenated) is legacy and increasingly missing on fresh installs. Use the V2 plugin.
  2. SIGTERM does not clean up. Runyard's default shutdown sends SIGTERM to docker compose up, then SIGKILL after a grace period. That stops the foreground compose process but leaves your containers running in the background. You need an explicit stopCommands entry that runs docker compose down so containers, networks, and volumes are torn down properly.

Working configuration

{
  "name": "Backend Stack",
  "type": "service",
  "directory": "~/Code/your-project",
  "autoStart": false,
  "startCommands": [{
    "label": "Compose",
    "command": "docker",
    "args": ["compose", "up"],
    "startupCheck": "http://localhost/api/health",
    "startupFallbackPort": 8000,
    "startupRequestTimeout": 30
  }],
  "stopCommands": [{
    "label": "Compose down",
    "command": "docker",
    "args": ["compose", "down"]
  }],
  "paths": ["/opt/homebrew/bin", "/Applications/Docker.app/Contents/Resources/bin"]
}

Replace the directory, the health URL path, and the fallback port with your own values.

Why this works

Prerequisites

Gotchas