DCA Docker Swarm & Orchestration 1 — Questions and Answers
Question 1: What command initializes a Docker Swarm and makes the current node a manager?
- docker swarm init (Correct answer)
- docker swarm create
- docker cluster init
- docker swarm start
Correct answer: docker swarm init
`docker swarm init` initializes a new Swarm on the current node and designates it as the first manager.
Question 2: Which TCP port does Docker Swarm use by default for manager-to-manager communication (Raft consensus)?
- 2375
- 2376
- 2377 (Correct answer)
- 7946
Correct answer: 2377
Port 2377 is reserved for Swarm cluster management communications between manager nodes.
Question 3: In Docker Swarm, what is a 'task'?
- A scheduled cron job running periodically in the cluster
- A running container instance that is part of a service (Correct answer)
- A configuration file defining service parameters
- A health check performed on service containers
Correct answer: A running container instance that is part of a service
A task is the atomic scheduling unit in Swarm — it represents a single running container that belongs to a service.
Question 4: What command retrieves the join token needed to add a worker node to an existing Swarm?
- docker swarm join-token worker (Correct answer)
- docker swarm token --worker
- docker node add --token worker
- docker swarm worker-token
Correct answer: docker swarm join-token worker
`docker swarm join-token worker` outputs the full `docker swarm join` command with the token required for a worker to join.
Question 5: What is the key difference between 'replicated' and 'global' service modes in Docker Swarm?
- Replicated services run on specific nodes; global services run on all nodes
- Replicated services run a specified number of task copies; global services run exactly one task on every available node (Correct answer)
- Replicated services use the ingress network; global services use host networking
- Replicated services support rolling updates; global services do not
Correct answer: Replicated services run a specified number of task copies; global services run exactly one task on every available node
In replicated mode you define a desired replica count; in global mode, the Swarm schedules exactly one task per available node.
Question 6: Which command lists all nodes currently participating in a Docker Swarm?
- docker node ls (Correct answer)
- docker swarm nodes
- docker cluster list
- docker ps --swarm
Correct answer: docker node ls
`docker node ls` lists every node in the Swarm along with its role, status, and availability.
Question 7: How do you scale a replicated service named 'web' to 5 replicas in Docker Swarm?
- docker service scale web 5
- docker service update --replicas 5 web
- docker service scale web=5 (Correct answer)
- docker swarm scale --service web --replicas 5
Correct answer: docker service scale web=5
`docker service scale web=5` is the correct syntax, using `name=count` format to set the desired replica count.
What command initializes a Docker Swarm and makes the current node a manager?