DCA Docker Swarm & Orchestration 2 — Questions and Answers
Question 1: What is the minimum number of manager nodes required so that a Docker Swarm can tolerate the failure of one manager?
- 1
- 2
- 3 (Correct answer)
- 4
Correct answer: 3
Three managers are the minimum for single-node fault tolerance because Raft requires a majority quorum (2 of 3) to remain operational.
Question 2: What does the Raft consensus algorithm provide in a Docker Swarm cluster?
- Load balancing of tasks across worker nodes
- Container-to-container networking between nodes
- Consistent distributed state management across manager nodes (Correct answer)
- Automatic service discovery for containers
Correct answer: Consistent distributed state management across manager nodes
Raft ensures all manager nodes agree on the cluster state and can elect a new leader if the current one fails, providing a consistent and fault-tolerant control plane.
Question 3: Which command sets the availability of a Swarm node named 'node1' to 'drain'?
- docker node update --availability drain node1 (Correct answer)
- docker swarm drain node1
- docker node drain node1
- docker node set --drain node1
Correct answer: docker node update --availability drain node1
`docker node update --availability drain node1` prevents new tasks from being scheduled on the node and reschedules existing tasks elsewhere.
Question 4: What is a Docker Stack in the context of Swarm mode?
- A collection of Docker images stored in a private registry
- A group of interrelated services deployed together using a Compose-format file (Correct answer)
- A set of Swarm manager nodes forming a control plane
- A storage driver for managing persistent volumes
Correct answer: A group of interrelated services deployed together using a Compose-format file
A Docker Stack bundles multiple services defined in a Compose file and deploys them as a unit to a Swarm, enabling multi-service orchestration.
Question 5: Which command deploys a stack named 'myapp' to a Swarm using 'docker-compose.yml'?
- docker stack deploy -c docker-compose.yml myapp (Correct answer)
- docker compose up --swarm myapp
- docker swarm deploy --file docker-compose.yml myapp
- docker stack create --compose docker-compose.yml myapp
Correct answer: docker stack deploy -c docker-compose.yml myapp
`docker stack deploy -c docker-compose.yml myapp` reads the Compose file and deploys the defined services as a stack to the active Swarm.
Question 6: What happens to a node's ability to run service tasks after it is promoted from worker to manager in Docker Swarm?
- All existing tasks on the node are immediately stopped
- The node stops running tasks and only handles management duties
- The node continues running tasks while also performing management functions (Correct answer)
- Tasks are migrated automatically to remaining worker nodes
Correct answer: The node continues running tasks while also performing management functions
Manager nodes participate in task scheduling by default and can run service tasks unless their availability is explicitly set to 'drain'.
Question 7: What is a service 'placement constraint' in Docker Swarm?
- A CPU/memory resource limit applied to service containers
- A rule that restricts which nodes are eligible to run a service's tasks (Correct answer)
- A maximum replica count enforced by the scheduler
- A health check condition required before a task is marked healthy
Correct answer: A rule that restricts which nodes are eligible to run a service's tasks
Placement constraints use node labels or built-in node properties to filter which nodes the Swarm scheduler may use when placing tasks for a service.
What is the minimum number of manager nodes required so that a Docker Swarm can tolerate the failure of one manager?