0
0
Dockerdevops~20 mins

Deploying services in Swarm in Docker - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Swarm Service Deployment Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Service replicas count after deployment

You deploy a service in Docker Swarm with the command:

docker service create --name webapp --replicas 3 nginx

What will be the output of docker service ls regarding the replicas column immediately after deployment?

Awebapp nginx replicated 0/3 running
Bwebapp nginx global 3/3 running
Cwebapp nginx replicated 3/0 running
Dwebapp nginx replicated 3/3 running
Attempts:
2 left
💡 Hint

Think about how quickly replicas start after service creation.

Configuration
intermediate
2:00remaining
Correct syntax for updating service replicas

You want to update an existing service named api to have 5 replicas. Which command is correct?

Adocker service update --replicas=5 api
Bdocker service update api --replicas 5
Cdocker service scale api=5
Ddocker service update --replica 5 api
Attempts:
2 left
💡 Hint

Check the correct order and spelling of flags in docker service update.

Troubleshoot
advanced
2:00remaining
Service fails to deploy with port conflict

You try to deploy a service with this command:

docker service create --name web --publish 80:80 nginx

But it fails with an error about port binding. What is the most likely cause?

APort 80 is already in use on one or more swarm nodes
BThe nginx image does not expose port 80
CThe service name 'web' is already used by another service
DDocker Swarm does not support publishing ports
Attempts:
2 left
💡 Hint

Consider what prevents binding to a port on the host.

🔀 Workflow
advanced
3:00remaining
Order of commands to deploy and scale a service

Arrange the steps in the correct order to deploy a service named db with 2 replicas and then scale it to 4 replicas.

A1,4,2,3
B2,1,3,4
C1,3,2,4
D1,2,4,3
Attempts:
2 left
💡 Hint

Think about deploying first, then checking status, then scaling.

Best Practice
expert
3:00remaining
Ensuring zero downtime during service update

You want to update a service's image without downtime. Which option ensures rolling updates with minimal disruption?

Adocker service update --image newimage:latest --force myservice
Bdocker service update --image newimage:latest --rollback myservice
Cdocker service update --image newimage:latest --update-parallelism 1 --update-delay 10s myservice
Ddocker service update --image newimage:latest --replicas 0 myservice
Attempts:
2 left
💡 Hint

Look for options controlling update speed and parallelism.