You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/reference/compose-file/deploy.md
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,40 +50,40 @@ services:
50
50
51
51
### mode
52
52
53
-
`mode`defines the replication model used to run the service on the platform. Either `global`, exactly one container per physical node, or `replicated`, a specified number of containers. The default is `replicated`.
53
+
`mode` defines the replication model used to run a service or job. Options include:
54
54
55
-
Two additional modes are available for jobs:
56
-
- `replicated-job`: A job that runs a specified number of tasks with controlled parallelism
57
-
- `global-job`: A job that runs once on each swarm node
55
+
1. **`global`**: Ensures exactly one task continuously runs per physical node until stopped.
56
+
2. **`replicated`**: Continuously runs a specified number of tasks across nodes until stopped (default).
57
+
3. **`replicated-job`**: Executes a defined number of tasks until a completion state (exits with code 0)'.
58
+
- Total tasks are determined by `replicas`.
59
+
- Concurrency can be limited using the `max-concurrent` option (CLI only).
60
+
4. **`global-job`**: Executes one task per physical node with a completion state (exits with code 0).
61
+
- Automatically runs on new nodes as they are added.
58
62
59
63
```yml
60
64
services:
61
65
frontend:
62
66
image: example/webapp
63
67
deploy:
64
68
mode: global
65
-
```
66
-
67
-
For job modes, additional parameters can be specified:
68
69
69
-
```yml
70
-
services:
71
70
batch-job:
72
71
image: example/processor
73
72
deploy:
74
73
mode: replicated-job
75
-
replicas: 1
76
-
max_concurrent: 2 # Maximum parallel job tasks
77
-
total_completions: 10 # Total number of times to run
74
+
replicas: 5
78
75
79
76
maintenance:
80
77
image: example/updater
81
78
deploy:
82
-
mode: global-job # Runs once on each node
79
+
mode: global-job
83
80
```
84
81
85
-
Note: Job modes are designed for tasks that have a finite completion state, unlike services which run continuously. Once a job completes, its containers exit but the service remains in the swarm until removed.
86
-
82
+
**Note**:
83
+
- Job modes (`replicated-job` and `global-job`) are designed for tasks that complete and exit with code 0.
84
+
- Completed tasks remain until explicitly removed.
85
+
- Options like `max-concurrent` for controlling concurrency are supported only via the CLI and are not available in Compose YAML.
86
+
- For more detailed information about job options and behavior, see the [Docker CLI documentation](/reference/cli/docker/service/create/#running-as-a-job)
0 commit comments