0
0
Dockerdevops~10 mins

Canary deployment pattern in Docker - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Canary deployment pattern
Start Deployment
Deploy New Version to Small Subset
Monitor Metrics & Logs
Is New Version Stable?
NoRollback to Old Version
Yes
Gradually Increase Traffic to New Version
Full Traffic Routed to New Version
Complete Deployment
The canary deployment gradually shifts traffic to a new version, monitoring stability before full rollout or rollback.
Execution Sample
Docker
docker service update --image myapp:v2 --limit-cpu 0.1 --replicas 1 myapp
# Monitor logs and metrics
# Increase replicas to 5 if stable
# Finally update replicas to 10 for full rollout
This sequence updates a Docker service to a new version with limited replicas, monitors it, then scales up if stable.
Process Table
StepActionReplicasTraffic % to New VersionStatusNotes
1Deploy new version with 1 replica110%RunningInitial canary deployment
2Monitor logs and metrics110%StableNo errors detected
3Increase replicas to 5550%RunningHalf traffic to new version
4Monitor logs and metrics550%StablePerformance good
5Increase replicas to 1010100%RunningFull traffic to new version
6Monitor logs and metrics10100%StableDeployment complete
7End10100%CompleteCanary deployment successful
💡 Full traffic routed to new version and deployment marked complete
Status Tracker
VariableStartAfter Step 1After Step 3After Step 5Final
Replicas10 (old version)1 (new version)5 (new version)10 (new version)10 (new version)
Traffic % to New Version0%10%50%100%100%
StatusRunning old versionRunning new versionRunning new versionRunning new versionComplete
Key Moments - 3 Insights
Why do we start with only 1 replica and 10% traffic instead of switching all at once?
Starting small limits risk. If the new version has issues, only a small part of users are affected. This is shown in execution_table steps 1 and 2 where only 1 replica handles 10% traffic.
What happens if the new version is not stable during monitoring?
If instability is detected, the deployment should rollback to the old version to avoid impacting users. This is the 'No' branch in the concept_flow after monitoring.
Why do we gradually increase replicas and traffic instead of jumping directly to full rollout?
Gradual increase allows catching problems early and ensures stability at each stage. Execution_table steps 3 and 5 show this gradual scaling.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the traffic percentage to the new version after step 3?
A50%
B10%
C100%
D0%
💡 Hint
Check the 'Traffic % to New Version' column at step 3 in the execution_table.
At which step does the deployment reach full traffic to the new version?
AStep 1
BStep 5
CStep 3
DStep 2
💡 Hint
Look for 100% traffic in the 'Traffic % to New Version' column in the execution_table.
If the new version was unstable at step 2, what would be the correct action?
AIncrease replicas to 5
BIncrease traffic to 50%
CRollback to old version
DComplete deployment anyway
💡 Hint
Refer to the concept_flow decision after monitoring metrics for stability.
Concept Snapshot
Canary Deployment Pattern:
- Deploy new version to small subset (e.g., 1 replica, 10% traffic)
- Monitor logs and metrics for stability
- Gradually increase traffic and replicas if stable
- Rollback immediately if issues detected
- Full rollout only after successful canary phase
Full Transcript
The canary deployment pattern is a safe way to release new software versions. It starts by deploying the new version to a small part of the system, like 1 replica handling 10% of traffic. Then, it monitors the system's health and performance. If stable, it gradually increases the number of replicas and traffic percentage to the new version. If any problems appear, it rolls back to the old version to protect users. This step-by-step approach reduces risk and ensures smooth updates.