Bird
Raised Fist0
Dockerdevops~20 mins

Canary deployment pattern in Docker - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Canary Deployment Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
What is the main purpose of a canary deployment?

Choose the best description of the canary deployment pattern in software delivery.

ARun two versions of software simultaneously for load balancing
BDeploy all changes to production at once to minimize downtime
CGradually roll out a new version to a small subset of users before full deployment
DAutomatically rollback all changes after deployment without testing
Attempts:
2 left
💡 Hint

Think about how to reduce risk when releasing new software.

💻 Command Output
intermediate
1:30remaining
What is the output of this Docker command during canary deployment?

Given the command below, what will it show?

docker service ls --filter name=myapp_canary
ALists all running services including the canary version named 'myapp_canary'
BShows an error because the filter syntax is incorrect
CLists only services not related to 'myapp_canary'
DShows no output because no services exist
Attempts:
2 left
💡 Hint

Check how Docker filters services by name.

❓ Configuration
advanced
2:00remaining
Which Docker Compose snippet correctly defines a canary deployment with 10% traffic?

Choose the correct Docker Compose service configuration to deploy a canary version receiving 10% of traffic using Docker Swarm.

Docker
version: '3.8'
services:
  web:
    image: myapp:stable
    deploy:
      replicas: 9
  web_canary:
    image: myapp:canary
    deploy:
      replicas: 1
AThe snippet above correctly sets 9 stable and 1 canary replica for 10% traffic
BThe canary service must have replicas: 0.1 to get 10% traffic
CThe snippet should use 'mode: global' for canary to get 10% traffic
DTraffic split is controlled by 'update_config' not replicas count
Attempts:
2 left
💡 Hint

Think about how replica counts relate to traffic distribution in Docker Swarm.

❓ Troubleshoot
advanced
2:00remaining
Why does the canary deployment not receive any traffic despite correct replica settings?

You deployed a canary service with 1 replica alongside 9 stable replicas. However, no user traffic reaches the canary. What is the most likely cause?

AThe stable service has zero replicas running
BThe canary service image is missing from the registry
CDocker Swarm does not support multiple replicas
DThe load balancer is not configured to route traffic to the canary service
Attempts:
2 left
💡 Hint

Consider how traffic routing works in a multi-service deployment.

🔀 Workflow
expert
2:30remaining
Order the steps for a safe canary deployment using Docker and monitoring tools

Arrange these steps in the correct order to perform a canary deployment safely.

A2,1,3,4
B1,3,2,4
C1,2,3,4
D3,1,2,4
Attempts:
2 left
💡 Hint

Think about deploying first, then routing traffic, monitoring, and finally full rollout.

Practice

(1/5)
1.

What is the main goal of a canary deployment in Docker?

easy
A. To update a small number of containers first to reduce risk
B. To update all containers at once for faster deployment
C. To delete old containers before deploying new ones
D. To run containers without any updates

Solution

  1. Step 1: Understand canary deployment purpose

    Canary deployment updates only a few containers initially to test changes safely.
  2. Step 2: Compare options

    Only To update a small number of containers first to reduce risk describes updating a small number of containers to reduce risk, which matches the canary deployment goal.
  3. Final Answer:

    To update a small number of containers first to reduce risk -> Option A
  4. Quick Check:

    Canary deployment = update few containers first [OK]
Hint: Canary means small test update first, not all at once [OK]
Common Mistakes:
  • Thinking canary updates all containers simultaneously
  • Confusing canary with blue-green deployment
  • Assuming canary deletes old containers immediately
2.

Which Docker command option controls how many containers update at the same time during a canary deployment?

docker service update --help

easy
A. --replicas
B. --update-delay
C. --update-parallelism
D. --rollback

Solution

  1. Step 1: Identify update control options

    Docker's --update-parallelism controls how many containers update simultaneously.
  2. Step 2: Differentiate from other options

    --update-delay controls wait time between updates, --replicas sets container count, and --rollback reverts updates.
  3. Final Answer:

    --update-parallelism -> Option C
  4. Quick Check:

    Parallelism = containers updated at once [OK]
Hint: Parallelism means how many update together [OK]
Common Mistakes:
  • Confusing delay with parallelism
  • Using replicas to control update speed
  • Thinking rollback controls update count
3.

Given the command:

docker service update --image myapp:v2 --update-parallelism 2 --update-delay 10s myservice

What happens during this update?

medium
A. Two containers update to v2, then wait 10 seconds before next two
B. Update fails because of wrong syntax
C. One container updates every 10 seconds until all are updated
D. All containers update to v2 immediately

Solution

  1. Step 1: Analyze update-parallelism

    It sets 2 containers to update at the same time.
  2. Step 2: Analyze update-delay

    It waits 10 seconds between each batch of updates.
  3. Final Answer:

    Two containers update to v2, then wait 10 seconds before next two -> Option A
  4. Quick Check:

    Parallelism=2 + Delay=10s means batch update with wait [OK]
Hint: Parallelism sets batch size; delay sets wait time [OK]
Common Mistakes:
  • Assuming all containers update instantly
  • Confusing delay as total update time
  • Thinking syntax is incorrect
4.

What is wrong with this command for canary deployment?

docker service update --image myapp:v2 --update-parallelism 0 --update-delay 5s myservice
medium
A. Delay cannot be less than 10 seconds
B. Service name must come before options
C. Image version syntax is incorrect
D. Parallelism cannot be zero; it must be at least 1

Solution

  1. Step 1: Check update-parallelism value

    Parallelism controls how many containers update at once and must be at least 1.
  2. Step 2: Validate other options

    Delay of 5s is valid; image syntax and option order are correct.
  3. Final Answer:

    Parallelism cannot be zero; it must be at least 1 -> Option D
  4. Quick Check:

    Parallelism=0 invalid, must be ≥1 [OK]
Hint: Parallelism must be ≥1, zero disables updates [OK]
Common Mistakes:
  • Setting parallelism to zero to pause updates
  • Thinking delay must be ≥10s
  • Misordering command options
5.

You want to deploy a new version of your app with canary deployment using Docker Swarm. You have 10 replicas. You want to update 3 containers at a time, wait 15 seconds between batches. Which command correctly implements this?

hard
A. docker service update --image myapp:v2 --update-parallelism 3 --update-delay 15s --rollback-condition on-failure myservice
B. docker service update --image myapp:v2 --update-parallelism 3 --update-delay 15s myservice
C. docker service update --image myapp:v2 --update-parallelism 3 --update-delay 15s --rollback-on-failure myservice
D. docker service update --image myapp:v2 --update-parallelism 3 --update-delay 15s --rollback myservice

Solution

  1. Step 1: Identify correct canary options

    --update-parallelism 3 and --update-delay 15s correctly set batch size and delay; no other flags needed.
  2. Step 2: Verify update options

    These match exactly in docker service update --image myapp:v2 --update-parallelism 3 --update-delay 15s myservice.
  3. Step 3: Check options in each command

    --rollback-condition and --rollback-on-failure are invalid; --rollback forces rollback instead of update.
  4. Final Answer:

    docker service update --image myapp:v2 --update-parallelism 3 --update-delay 15s myservice -> Option B
  5. Quick Check:

    Parallelism + delay with valid flags only [OK]
Hint: Parallelism sets batch size; delay sets wait; avoid invalid flags [OK]
Common Mistakes:
  • Adding invalid rollback flags
  • Missing parallelism or delay options
  • Assuming rollback must be specified
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard