0
0
Dockerdevops~20 mins

Scaling services with replicas in Docker - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Replica Scaling Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Scaling a Docker service to 3 replicas
You run the command docker service scale webapp=3 on a Docker Swarm cluster. What is the expected state of the service webapp after this command?
AThe service <code>webapp</code> will have 3 replicas on the same node only.
BThe service <code>webapp</code> will be removed and recreated with 3 replicas.
CThe service <code>webapp</code> will have exactly 3 running replicas across the swarm nodes.
DThe command will fail because scaling requires a Docker Compose file.
Attempts:
2 left
💡 Hint
Think about how Docker Swarm manages service replicas across nodes.
🧠 Conceptual
intermediate
2:00remaining
Understanding replica distribution in Docker Swarm
In Docker Swarm, when you scale a service to multiple replicas, how does Swarm decide where to place these replicas?
ASwarm places all replicas on the manager node by default.
BSwarm distributes replicas evenly across worker nodes based on resource availability.
CSwarm places replicas only on nodes with the least CPU usage, ignoring memory.
DSwarm randomly places replicas without considering node resources.
Attempts:
2 left
💡 Hint
Think about how a cluster balances workload.
Configuration
advanced
2:00remaining
Docker Compose file for scaling a service
Which Docker Compose snippet correctly defines a service named api with 4 replicas in a Docker Swarm stack?
A
services:
  api:
    image: myapi:latest
    deploy:
      replicas: 4
B
services:
  api:
    image: myapi:latest
    scale: 4
C
services:
  api:
    image: myapi:latest
    deploy:
      scale: 4
D
services:
  api:
    image: myapi:latest
    replicas: 4
Attempts:
2 left
💡 Hint
Look for the correct key under deploy for replicas.
Troubleshoot
advanced
2:00remaining
Troubleshooting failed scaling of a service
You tried to scale a service to 5 replicas using docker service scale, but only 3 replicas are running. What is the most likely cause?
AThe <code>docker service scale</code> command only supports scaling up to 3 replicas.
BThe service image is missing from the Docker Hub registry.
CThe swarm manager node is offline.
DThere are not enough nodes or resources available in the swarm to run 5 replicas.
Attempts:
2 left
💡 Hint
Consider cluster resource limits and node availability.
🔀 Workflow
expert
3:00remaining
Correct sequence to scale a Docker Swarm service
Arrange the steps in the correct order to scale a Docker Swarm service named frontend from 2 to 5 replicas.
A1,2,3,4
B2,1,3,4
C1,3,2,4
D1,2,4,3
Attempts:
2 left
💡 Hint
Think about checking before and after scaling, then confirming service health.