Bird
Raised Fist0
Dockerdevops~20 mins

Container orchestration in production in Docker - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Container Orchestration Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of this Docker Swarm service command?
You run the command docker service ls in a Docker Swarm cluster. What output will you see if there are two services named webapp and db running with 3 and 1 replicas respectively?
Docker
docker service ls
A
ID                  NAME                MODE                REPLICAS            IMAGE               PORTS
x1y2z3              webapp              replicated          3/3                 webapp:latest       *:80->80/tcp
x4y5z6              db                  replicated          1/1                 db:latest           
B
ID                  NAME                MODE                REPLICAS            IMAGE               PORTS
x1y2z3              webapp              global              3/3                 webapp:latest       *:80->80/tcp
x4y5z6              db                  replicated          1/1                 db:latest           
C
ID                  NAME                MODE                REPLICAS            IMAGE               PORTS
x1y2z3              webapp              replicated          2/3                 webapp:latest       *:80->80/tcp
x4y5z6              db                  replicated          1/1                 db:latest           
D
ID                  NAME                MODE                REPLICAS            IMAGE               PORTS
x1y2z3              webapp              replicated          3/3                 webapp:latest       
x4y5z6              db                  replicated          1/1                 db:latest           
Attempts:
2 left
💡 Hint
Look carefully at the MODE and REPLICAS columns for each service.
🧠 Conceptual
intermediate
1:30remaining
Which orchestration feature ensures your app keeps running even if a node fails?
In container orchestration, what feature helps maintain application availability when a physical or virtual machine hosting containers crashes?
ALoad balancing
BImage caching
CService discovery
DSelf-healing
Attempts:
2 left
💡 Hint
Think about automatic recovery without manual intervention.
❓ Configuration
advanced
2:30remaining
Identify the correct Docker Compose snippet for scaling a service
Which Docker Compose YAML snippet correctly configures the web service to run 5 replicas in a production swarm?
A
version: '3.8'
services:
  web:
    image: myapp:latest
    replicas: 5
    restart_policy:
      condition: on-failure
B
version: '3.8'
services:
  web:
    image: myapp:latest
    deploy:
      replicas: 5
      restart_policy:
        condition: on-failure
C
version: '3.8'
services:
  web:
    image: myapp:latest
    deploy:
      mode: global
      replicas: 5
D
version: '3.8'
services:
  web:
    image: myapp:latest
    deploy:
      replicas: '5'
      restart_policy:
        condition: any
Attempts:
2 left
💡 Hint
Replicas must be under deploy and be a number, not a string.
❓ Troubleshoot
advanced
2:00remaining
Why does this Kubernetes pod stay in Pending state?
You deployed a pod with this YAML snippet but it stays in Pending state indefinitely. What is the most likely cause?
apiVersion: v1
kind: Pod
metadata:
  name: test-pod
spec:
  containers:
  - name: test-container
    image: nginx
  nodeSelector:
    disktype: ssd
ANo nodes in the cluster have the label <code>disktype=ssd</code>
BThe image <code>nginx</code> is not available in the registry
CThe pod spec is missing resource limits
DThe pod name is invalid
Attempts:
2 left
💡 Hint
Check if the node labels match the pod's nodeSelector.
🔀 Workflow
expert
3:00remaining
Order the steps to safely update a production Kubernetes deployment with zero downtime
Arrange these steps in the correct order to perform a rolling update on a Kubernetes deployment ensuring zero downtime.
A1,2,4,3
B2,1,3,4
C1,2,3,4
D1,3,2,4
Attempts:
2 left
💡 Hint
Think about editing first, then applying, then monitoring, then verifying.

Practice

(1/5)
1. What is the main purpose of container orchestration in production environments?
easy
A. To manage and automate deployment, scaling, and operation of multiple containers
B. To write code inside containers
C. To create container images manually
D. To monitor CPU usage on a single container

Solution

  1. Step 1: Understand container orchestration role

    Container orchestration automates managing many containers, including deployment and scaling.
  2. Step 2: Compare options

    Only To manage and automate deployment, scaling, and operation of multiple containers describes managing and automating container groups, which is orchestration's goal.
  3. Final Answer:

    To manage and automate deployment, scaling, and operation of multiple containers -> Option A
  4. Quick Check:

    Orchestration = Manage & automate containers [OK]
Hint: Orchestration means managing many containers automatically [OK]
Common Mistakes:
  • Confusing orchestration with coding inside containers
  • Thinking orchestration is about creating images manually
  • Believing orchestration only monitors single container stats
2. Which Docker Swarm command is used to create a new service in a cluster?
easy
A. docker service create
B. docker container run
C. docker swarm init
D. docker network create

Solution

  1. Step 1: Identify command for creating services

    The command docker service create is used to start a new service in Docker Swarm.
  2. Step 2: Eliminate other commands

    docker container run runs containers but not as a managed service; docker swarm init initializes the swarm; docker network create creates networks.
  3. Final Answer:

    docker service create -> Option A
  4. Quick Check:

    Service creation = docker service create [OK]
Hint: Service creation uses 'docker service create' command [OK]
Common Mistakes:
  • Using 'docker container run' to create services
  • Confusing swarm initialization with service creation
  • Mixing network commands with service commands
3. What will be the output of the command docker service ls in a Docker Swarm cluster?
medium
A. List of all running containers on the host
B. List of all services running in the swarm with their replicas
C. List of all Docker images available locally
D. List of all networks created in Docker

Solution

  1. Step 1: Understand the command purpose

    docker service ls shows all services in the swarm, including how many replicas each has.
  2. Step 2: Compare with other options

    It lists services and replicas, not individual containers (<code>docker ps</code>), images (<code>docker images</code>), or networks (<code>docker network ls</code>).
  3. Final Answer:

    List of all services running in the swarm with their replicas -> Option B
  4. Quick Check:

    docker service ls = list swarm services [OK]
Hint: 'docker service ls' lists swarm services, not containers [OK]
Common Mistakes:
  • Thinking it lists individual containers
  • Confusing services with images or networks
  • Expecting detailed container logs from this command
4. You run docker service scale myservice=5 but only 3 containers start. What is the likely cause?
medium
A. The command syntax is wrong
B. The service name is incorrect
C. Docker daemon is not running
D. Not enough resources on swarm nodes to run 5 replicas

Solution

  1. Step 1: Analyze the scaling command

    The command syntax is correct and service name is assumed valid since some containers started.
  2. Step 2: Identify resource constraints

    If only 3 replicas run instead of 5, likely the swarm nodes lack enough CPU/memory to start all replicas.
  3. Final Answer:

    Not enough resources on swarm nodes to run 5 replicas -> Option D
  4. Quick Check:

    Scaling fails due to resource limits [OK]
Hint: Scaling fails if swarm nodes lack resources [OK]
Common Mistakes:
  • Assuming command syntax is wrong
  • Thinking service name is invalid if some replicas run
  • Ignoring resource limits on nodes
5. In a production Docker Swarm, how can you ensure your service stays running even if a node fails?
hard
A. Use 'docker container run' repeatedly on the same node
B. Run the service with a single replica on one node only
C. Set the service replicas to more than one so tasks run on multiple nodes
D. Disable swarm mode to avoid node failures

Solution

  1. Step 1: Understand high availability in swarm

    Running multiple replicas spreads tasks across nodes, so if one node fails, others keep running the service.
  2. Step 2: Evaluate options

    Single replica or running containers manually does not provide failover. Disabling swarm removes orchestration benefits.
  3. Final Answer:

    Set the service replicas to more than one so tasks run on multiple nodes -> Option C
  4. Quick Check:

    Multiple replicas = high availability [OK]
Hint: Use multiple replicas for failover in swarm [OK]
Common Mistakes:
  • Running only one replica expecting failover
  • Manually running containers without orchestration
  • Disabling swarm mode to fix node failures
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