Blue/Green Deploys with Docker Compose

Two stacks, one proxy flip, instant rollback, no orchestrator required.

Owner: Marcus BellPlatform OpsContact ownerAdded 27 Jul 2026Updated 14 Sep 2026
  • Runs out of the box: yes
  • Tests: yes
  • CI: no
  • Docs: yes
  • Used in production: no

Purpose#

A pair of Compose projects (blue and green) behind a small reverse proxy. A deploy script starts the idle stack with the new image, waits for its health endpoint, flips the proxy to it and leaves the old stack running for a grace period so a rollback is another flip.

It targets internal tools that run on a single host where a full orchestrator would be more machinery than the application.

What you will learn#

  1. Run two parallel Compose stacks and switch traffic with a proxy configuration change
  2. Gate a traffic switch on a health endpoint
  3. Roll back by flipping the proxy to the previous stack

Technologies & features#

Technologies
BashDocker ComposeDocker
Features
Blue-Green DeploymentHealth CheckContainer Deployment
Topics
Deployment & Infrastructureprimary

Lessons learned#

  • Worked

    Leaving the old stack running for ten minutes turned most bad releases into a one-command rollback.

  • Didn’t work

    Database migrations that were not backwards compatible made rollback unsafe. The deploy script now refuses to flip when a migration is flagged as breaking.

Try it#

Shell
git clone https://git.example.internal/platform-ops/bluegreen-compose.git
cd bluegreen-compose
./deploy.sh demo:1.0.0   # first deploy -> blue
./deploy.sh demo:1.1.0   # deploys green, flips, keeps blue
./rollback.sh

Commands come from the owner’s README. Credentials are never stored here.

Resources#

Contributes to

StatusReference
OwnerMarcus Bell
TeamPlatform Ops
Last commit11 Sep 2026
Slugblue-green-docker-compose
Report a problem to the owner