Q. What is the default number of replicas if not specified when creating a Swarm service?

  • (A) 1
  • (B) 2
  • (C) 3
  • (D) 0
πŸ’¬ Discuss
βœ… Correct Answer: (A) 1
Explanation: If not specified, Docker Swarm creates a service with a single replica by default.

Q. How does Docker Swarm handle load balancing?

  • (A) Using a third-party plugin
  • (B) Via built-in routing mesh
  • (C) Through NGINX
  • (D) It does not handle load balancing
πŸ’¬ Discuss
βœ… Correct Answer: (B) Via built-in routing mesh
Explanation: Docker Swarm has a built-in routing mesh that distributes network traffic to the containers.

Q. What happens when a Swarm manager node fails?

  • (A) All containers stop
  • (B) The Swarm becomes unusable
  • (C) A new manager is elected from the other manager nodes
  • (D) Docker Swarm shuts down
πŸ’¬ Discuss
βœ… Correct Answer: (C) A new manager is elected from the other manager nodes
Explanation: Docker Swarm uses Raft consensus to elect a new manager automatically in case of failure.

Q. What is the role of a worker node in Docker Swarm?

  • (A) Manage other nodes
  • (B) Deploy services and manage tasks
  • (C) Maintain service states
  • (D) Only logs events
πŸ’¬ Discuss
βœ… Correct Answer: (B) Deploy services and manage tasks
Explanation: Worker nodes in Docker Swarm execute tasks assigned by manager nodes.

Q. What command updates the image of a running service?

  • (A) docker service upgrade
  • (B) docker update image
  • (C) docker service update
  • (D) docker image update
πŸ’¬ Discuss
βœ… Correct Answer: (C) docker service update
Explanation: `docker service update --image` is used to update a service to a new image version.

Q. Which command removes a service in Docker Swarm?

  • (A) docker service remove
  • (B) docker rm service
  • (C) docker swarm delete
  • (D) docker service down
πŸ’¬ Discuss
βœ… Correct Answer: (A) docker service remove
Explanation: `docker service remove` is used to delete a service from the Swarm.

Q. How do you scale a service in Docker Swarm?

  • (A) docker scale service
  • (B) docker service scale
  • (C) docker service resize
  • (D) docker swarm scale
πŸ’¬ Discuss
βœ… Correct Answer: (B) docker service scale
Explanation: `docker service scale` allows you to increase or decrease the number of replicas.

Q. What is a task in Docker Swarm?

  • (A) A Dockerfile step
  • (B) A single running container
  • (C) A log entry
  • (D) A plugin
πŸ’¬ Discuss
βœ… Correct Answer: (B) A single running container
Explanation: In Docker Swarm, a task represents a single container created as part of a service.

Q. Which of the following best describes a manager node?

  • (A) Runs background tasks
  • (B) Only deploys containers
  • (C) Manages the cluster and schedules tasks
  • (D) Monitors the health of services only
πŸ’¬ Discuss
βœ… Correct Answer: (C) Manages the cluster and schedules tasks
Explanation: Manager nodes maintain cluster state, schedule services, and orchestrate the worker nodes.

Q. What is the main purpose of the Raft protocol in Swarm?

  • (A) Encrypt container logs
  • (B) Share files across containers
  • (C) Maintain consensus and state across manager nodes
  • (D) Distribute Docker images
πŸ’¬ Discuss
βœ… Correct Answer: (C) Maintain consensus and state across manager nodes
Explanation: The Raft protocol ensures consistency in the distributed key-value store used by manager nodes.