Blue/Green Deploys with Docker Compose
Two stacks, one proxy flip, instant rollback, no orchestrator required.
- 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#
- Run two parallel Compose stacks and switch traffic with a proxy configuration change
- Gate a traffic switch on a health endpoint
- 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#
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.shCommands come from the owner’s README. Credentials are never stored here.

