Challenge your understanding of Docker Swarm mode and container orchestration concepts with this focused quiz. Explore nodes, services, scaling, networking, and key commands essential for managing orchestration in clustered environments.
Which command initializes a new Swarm cluster and designates the node as a manager?
Explanation: The correct command to initialize a new Swarm and make the node a manager is 'docker swarm init'. 'docker swarm start' is not a valid command and would result in an error. 'docker cluster initialize' sounds similar but does not exist. 'docker swarm manager' is also incorrect, as it does not represent any recognized command for this purpose.
In Docker Swarm mode, what is the primary role of a worker node within a cluster?
Explanation: Worker nodes primarily execute tasks (containers) assigned by the manager but do not participate in decision-making. They are not involved in electing managers, which is a responsibility of manager nodes. Workers do handle network traffic for their services but are not restricted to that role alone. Assigning services to other nodes is a task reserved for the manager nodes.
If a service is deployed with three replicas in Swarm mode, what happens when the scale is increased to five?
Explanation: When scaling from three to five, Swarm adds two new containers to reach the requested replica count without disrupting the existing ones. The service does not stop and restart all containers as this would interrupt uptime. Removing all existing containers and recreating five is unnecessary and not the default behavior. The cluster does not reset automatically during scaling operations.
What is the primary purpose of an overlay network in Swarm mode for containers across multiple nodes?
Explanation: Overlay networks enable containers running on different nodes in a cluster to communicate with each other as if they were on the same network. Automatically assigning external IPs is not the primary function. Overlay networks do the opposite of restricting containers to a single host; they allow multi-host communication. The main goal is not to speed up container startup time, though networking configuration can slightly affect startup speed.
Which command is used in Swarm mode to update the image of an existing running service?
Explanation: The 'docker service update' command allows you to modify a running service, including changing its image. 'docker service refresh' and 'docker update service' are invalid and would not perform the update. 'docker swarm restart' does not exist as a command and restarting is not the proper mechanism for updating service images.