Skip to content

Blue-Green Deploys for Stacks

A blue-green deploy starts the new version of a service beside the running one, checks it, and moves traffic only when the check passes. This page covers stack services and standalone Compose applications. For single-container applications, see Blue-green deploys in the deployments overview.

A service rolls out blue-green when either of these is true:

  • The service has blue-green on in its own Settings.
  • The stack has it on (Deploys in the stack’s Settings, or reoclo groups config set <stack> --blue-green on) and the service has a health check.

The health check comes from the service’s healthcheck: in the Compose file, which Reoclo reads when it scans the stack, or from a check you set on the service in Reoclo. A standalone Compose application works the same way: set its health check in the application’s Settings.

Some services can’t run beside themselves. Compose replaces them the standard way, and the deploy log says why, when the service sets container_name or network_mode, or when it publishes a host port. On a server whose proxy Reoclo manages, Reoclo doesn’t publish the host ports from your Compose file, so they don’t block a rollout there.

One-shot services (a migration that exits, for example) and services without a health check are never gated. See Ungated and one-shot services.

  1. Compose creates the new container beside the running one, named <project>-<service>-2 (the next index).
  2. Reoclo holds back its network aliases while it starts, so nothing reaches it by service name and the managed proxy can’t reach it through its reoclo-app-<id> alias. The new container still reaches the rest of the stack.
  3. When the check passes, the new container rejoins each network with its aliases, on the address it already has. It also joins any network the old container was attached to outside Compose.
  4. The old container drops its aliases first, then gets 30 seconds to stop.

From then on, callers that use the service name and the managed proxy reach the new container.

Published host ports can’t move between containers. A service that publishes one keeps the standard replace for that reason.

The gate decides whether the new container takes over. How it decides depends on whether the container has a Docker health check.

The container has a Docker health check (the Compose healthcheck:, or a HEALTHCHECK in the image). Reoclo waits for Docker to report the new container healthy. Docker runs the check with its own interval, timeout, retries and start_period, the same way docker compose ps shows it. The gate passes on healthy and fails on unhealthy. A container that exits fails it at once, and so does a wait that runs out.

The wait is at most:

start_period + interval + retries x (interval + timeout) + 15 seconds

capped at 15 minutes. Where a field is unset, Docker’s defaults apply: interval 30s, timeout 30s, retries 3, start_period 0. With all defaults the gate waits up to 225 seconds.

The container has no Docker health check. Reoclo runs the service’s own check inside the new container’s network: an HTTP or TCP check against the container port, or a command run in the container with docker exec. An HTTP check sends the method and path you set and passes on a 2xx or 3xx status. Reoclo waits the check’s start period, then tries up to retries times, interval apart, giving each try timeout seconds. The defaults are a 10s start period, 3 retries, a 30s interval and a 10s timeout.

An HTTP check keeps its connection open until the response arrives. Node.js servers (Express, Hono and Astro SSR among them) drop a request when the client closes its sending side before an async handler answers. Reoclo’s check used to close it early, which made healthy Node services fail their rollout.

The deploy log for a gated service has:

  • One line saying which check gates the service: Docker’s health check with its command and timing, or Reoclo’s check.
  • One line per attempt: its UTC time and exit code, then what the code means and the first line of the check’s output.

When a gate fails, the log also shows the new container’s state before Reoclo removes it: running or exited, its exit code, whether it ran out of memory, and its last 10 log lines.

A stack deploy with gated services runs in this order:

  1. Services that the gated services depend on (depends_on, followed through, one-shot migrations included) are updated first, so the new version starts against the migrated database.
  2. The gated services roll out one at a time. Each one is checked on its own, so a failed gate doesn’t stop the next service’s rollout.
  3. The remaining services, the ones no gated service depends on (workers, for example), are updated only after every gate has passed.
  4. Verify reads the health of every container now serving.

If a gate fails, step 3 never happens. Those services aren’t touched and stay on the previous deployment. Reoclo calls them held. The deployment ends partial, and its result names the services that were rolled back and the services that were held.

A service Compose recreates without a gate is stopped before its replacement starts, so it has a short gap. The deploy log names each service Compose replaced in place because it has no health check. A blue-green service that can’t run beside itself gets its own line saying why.

One-shot services run as part of the order above and aren’t gated. A migration that exits runs in step 1 when a gated service depends on it.

Without force, a gated service rolls out only when Compose would recreate it, because its image or configuration changed. A forced redeploy rolls out every gated service even when nothing changed. Use reoclo groups deploy <stack> --force-recreate, or tick Force recreate containers when you deploy the stack from the dashboard.

A scoped redeploy, reoclo groups redeploy <stack> <service>, rolls out only that service. Add --force-recreate to roll it out when nothing changed.

partial means some services moved to the new deployment and others didn’t. After a failed gate, the stack looks like this:

  • The service whose gate failed has outcome rolled_back. Its previous container is still serving, and its reason reads like “rolled back: its health check failed (Docker reports it unhealthy after 3 failed checks). The previous container is still serving.”
  • Services that were held have outcome held, with a reason naming the gate that held them.

Gated services that passed have outcome recreated, as they do in any stack deployment. So do the dependencies from step 1, which are already on the new version.

The stack deployment has a rollout stage between up and verify whenever it rolled something out. The stage fails when a gate failed, and its log holds the gate lines. The verify stage reports the containers now serving and marks a rolled-back service’s line as its previous container.

To recover, fix the cause the log names and deploy again. To abandon blue-green for now, turn it off and deploy: every service is then replaced the standard way.

Services from step 1 are already on the new version when a later gate fails. During a rollout, and after a failed one, the previous version of a service runs against the migrated database. Write migrations so that both versions work: add columns and tables first (expand), and remove the old ones in a later release, once nothing running uses them (contract). Work that must happen once needs a lock, because two versions of a service run at the same time.

CommandWhat it does
reoclo groups config set <stack> --blue-green onTurns blue-green on or off for the whole stack.
reoclo groups get <stack>Shows blue_green (-o json includes it). reoclo groups ls has a BLUE-GREEN column.
reoclo groups deploy <stack> --force-recreateRolls out every gated service, changed or not.
reoclo groups deployment <stack> <n>Lists the rollout stage and each service’s reason, including rolled-back and held services.

See reoclo groups for every flag.