This is a demo repo exploring how to support blue/green deployments with zero downtime using Traefik. It's based on Max Countryman's blog post.
It's not intended for production use right away - the Traefik dashboard and API are unsecured and there's no TLS.
Start the Traefik reverse proxy:
docker compose --c=traefik --file docker-compose.traefik.yml up --detach
Access the Traefik dashboard at http://localhost:8080/dashboard
Run the ./deploy
deployment script:
Starting blue-web container
[+] Running 1/1
✔ Container blue-web Started 0.1s
Waiting for blue-web to become healthy...
blue-web is healthy
Checking if Traefik recognizes blue-web...
Traefik recognizes blue-web as healthy
A sample web app should deploy and become accessible at http://localhost.
Run docker ps
and you should see the blue-web
container running:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d9ba1d66fc75 nginxdemos/hello:latest "/docker-entrypoint.…" 59 seconds ago Up 59 seconds 80/tcp blue-web
0270e2e71273 traefik:v2.9 "/entrypoint.sh trae…" 36 minutes ago Up About a minute 0.0.0.0:80->80/tcp, 127.0.0.1:8080->8080/tcp traefik
Run the deployment script again to simulate a new version.
Now docker ps
shows that the green container is running and the blue container has been stopped:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
95881a3001b1 nginxdemos/hello:latest "/docker-entrypoint.…" 39 seconds ago Up 38 seconds 80/tcp green-web
0270e2e71273 traefik:v2.9 "/entrypoint.sh trae…" 37 minutes ago Up 2 minutes 0.0.0.0:80->80/tcp, 127.0.0.1:8080->8080/tcp traefik