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.- 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.- 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
| Service Type | Replica Count | Scheduling Behavior | Common Use Case |
|---|---|---|---|
| Replicated | User-defined (N) | Distributes tasks evenly | Scalable web apps, microservices |
| Global | One per node | Runs exactly one task on each node | Agents for logging, monitoring |