Skip to main content
In Docker Swarm, services define how containers are deployed and managed across a cluster. Swarm supports two primary service modes: replicated and global. This guide explains each mode, shows how to deploy them, and compares their use cases.

Replicated Service

A replicated service launches a specified number of identical tasks (containers). This is the default mode in Swarm.
If you omit --replicas, Swarm defaults to 1 replica. You can also explicitly set --mode replicated if you prefer.
To deploy five replicas of a web service:
Verify the service mode and replica count:
Sample output:
Key points for replicated services:
  • Tasks are spread evenly across available nodes.
  • Scale up or down by updating --replicas.
  • Ideal for stateless applications like web servers or APIs.

Global Service

A global service ensures exactly one task runs on every node in the Swarm.
Do not specify --replicas with global services. Use only --mode global.
To deploy a monitoring agent on all nodes:
Global mode behavior:
  • New nodes automatically receive one task.
  • When a node leaves, its task is removed and not rescheduled.
  • Perfect for logging, monitoring, and security daemons.

Comparison Table

References

Watch Video