Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -105,3 +105,12 @@ You start the Docker daemon with the command line. How you start the daemon affe |
| 105 | 105 |
* [swarm leave](swarm_leave.md) |
| 106 | 106 |
* [swarm update](swarm_update.md) |
| 107 | 107 |
|
| 108 |
+### Swarm service commands |
|
| 109 |
+ |
|
| 110 |
+* [service create](service_create.md) |
|
| 111 |
+* [service inspect](service_inspect.md) |
|
| 112 |
+* [service ls](service_ls.md) |
|
| 113 |
+* [service rm](service_rm.md) |
|
| 114 |
+* [service scale](service_scale.md) |
|
| 115 |
+* [service tasks](service_tasks.md) |
|
| 116 |
+* [service update](service_update.md) |
| 108 | 117 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,157 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "service create" |
|
| 2 |
+description = "The service create command description and usage" |
|
| 3 |
+keywords = ["service, create"] |
|
| 4 |
+ |
|
| 5 |
+[menu.main] |
|
| 6 |
+parent = "smn_cli" |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+**Warning:** this command is part of the Swarm management feature introduced in Docker 1.12, and might be subject to non backward-compatible changes. |
|
| 10 |
+ |
|
| 11 |
+# service create |
|
| 12 |
+ |
|
| 13 |
+```Markdown |
|
| 14 |
+Usage: docker service create [OPTIONS] IMAGE [COMMAND] [ARG...] |
|
| 15 |
+ |
|
| 16 |
+Create a new service |
|
| 17 |
+ |
|
| 18 |
+Options: |
|
| 19 |
+ --constraint value Placement constraints (default []) |
|
| 20 |
+ --endpoint-mode string Endpoint mode(Valid values: VIP, DNSRR) |
|
| 21 |
+ -e, --env value Set environment variables (default []) |
|
| 22 |
+ --help Print usage |
|
| 23 |
+ -l, --label value Service labels (default []) |
|
| 24 |
+ --limit-cpu value Limit CPUs (default 0.000) |
|
| 25 |
+ --limit-memory value Limit Memory (default 0 B) |
|
| 26 |
+ --mode string Service mode (replicated or global) (default "replicated") |
|
| 27 |
+ -m, --mount value Attach a mount to the service |
|
| 28 |
+ --name string Service name |
|
| 29 |
+ --network value Network attachments (default []) |
|
| 30 |
+ -p, --publish value Publish a port as a node port (default []) |
|
| 31 |
+ --replicas value Number of tasks (default none) |
|
| 32 |
+ --reserve-cpu value Reserve CPUs (default 0.000) |
|
| 33 |
+ --reserve-memory value Reserve Memory (default 0 B) |
|
| 34 |
+ --restart-condition string Restart when condition is met (none, on_failure, or any) |
|
| 35 |
+ --restart-delay value Delay between restart attempts (default none) |
|
| 36 |
+ --restart-max-attempts value Maximum number of restarts before giving up (default none) |
|
| 37 |
+ --restart-window value Window used to evalulate the restart policy (default none) |
|
| 38 |
+ --stop-grace-period value Time to wait before force killing a container (default none) |
|
| 39 |
+ --update-delay duration Delay between updates |
|
| 40 |
+ --update-parallelism uint Maximum number of tasks updated simultaneously |
|
| 41 |
+ -u, --user string Username or UID |
|
| 42 |
+ -w, --workdir string Working directory inside the container |
|
| 43 |
+``` |
|
| 44 |
+ |
|
| 45 |
+Creates a service as described by the specified parameters. This command has to |
|
| 46 |
+be run targeting a manager node. |
|
| 47 |
+ |
|
| 48 |
+## Examples |
|
| 49 |
+ |
|
| 50 |
+### Create a service |
|
| 51 |
+ |
|
| 52 |
+```bash |
|
| 53 |
+$ docker service create --name redis redis:3.0.6 |
|
| 54 |
+dmu1ept4cxcfe8k8lhtux3ro3 |
|
| 55 |
+ |
|
| 56 |
+$ docker service ls |
|
| 57 |
+ID NAME REPLICAS IMAGE COMMAND |
|
| 58 |
+dmu1ept4cxcf redis 1/1 redis:3.0.6 |
|
| 59 |
+``` |
|
| 60 |
+ |
|
| 61 |
+### Create a service with 5 tasks |
|
| 62 |
+ |
|
| 63 |
+You can set the number of tasks for a service using the `--replicas` option. The |
|
| 64 |
+following command creates a `redis` service with `5` tasks: |
|
| 65 |
+ |
|
| 66 |
+```bash |
|
| 67 |
+$ docker service create --name redis --replicas=5 redis:3.0.6 |
|
| 68 |
+4cdgfyky7ozwh3htjfw0d12qv |
|
| 69 |
+``` |
|
| 70 |
+ |
|
| 71 |
+The above command sets the *desired* number of tasks for the service. Even |
|
| 72 |
+though the command returns directly, actual scaling of the service may take |
|
| 73 |
+some time. The `REPLICAS` column shows both the *actual* and *desired* number |
|
| 74 |
+of tasks for the service. |
|
| 75 |
+ |
|
| 76 |
+In the following example, the desired number of tasks is set to `5`, but the |
|
| 77 |
+*actual* number is `3` |
|
| 78 |
+ |
|
| 79 |
+```bash |
|
| 80 |
+$ docker service ls |
|
| 81 |
+ID NAME REPLICAS IMAGE COMMAND |
|
| 82 |
+4cdgfyky7ozw redis 3/5 redis:3.0.7 |
|
| 83 |
+``` |
|
| 84 |
+ |
|
| 85 |
+Once all the tasks are created, the actual number of tasks is equal to the |
|
| 86 |
+desired number: |
|
| 87 |
+ |
|
| 88 |
+```bash |
|
| 89 |
+$ docker service ls |
|
| 90 |
+ID NAME REPLICAS IMAGE COMMAND |
|
| 91 |
+4cdgfyky7ozw redis 5/5 redis:3.0.7 |
|
| 92 |
+``` |
|
| 93 |
+ |
|
| 94 |
+ |
|
| 95 |
+### Create a service with a rolling update constraints |
|
| 96 |
+ |
|
| 97 |
+ |
|
| 98 |
+```bash |
|
| 99 |
+$ docker service create \ |
|
| 100 |
+ --replicas 10 \ |
|
| 101 |
+ --name redis \ |
|
| 102 |
+ --update-delay 10s \ |
|
| 103 |
+ --update-parallelism 2 \ |
|
| 104 |
+ redis:3.0.6 |
|
| 105 |
+``` |
|
| 106 |
+ |
|
| 107 |
+When this service is [updated](service_update.md), a rolling update will update |
|
| 108 |
+tasks in batches of `2`, with `10s` between batches. |
|
| 109 |
+ |
|
| 110 |
+### Setting environment variables (-e --env) |
|
| 111 |
+ |
|
| 112 |
+This sets environmental variables for all tasks in a service. For example: |
|
| 113 |
+ |
|
| 114 |
+```bash |
|
| 115 |
+$ docker service create --name redis_2 --replicas 5 --env MYVAR=foo redis:3.0.6 |
|
| 116 |
+``` |
|
| 117 |
+ |
|
| 118 |
+### Set metadata on a service (-l --label) |
|
| 119 |
+ |
|
| 120 |
+A label is a `key=value` pair that applies metadata to a service. To label a |
|
| 121 |
+service with two labels: |
|
| 122 |
+ |
|
| 123 |
+```bash |
|
| 124 |
+$ docker service create \ |
|
| 125 |
+ --name redis_2 \ |
|
| 126 |
+ --label com.example.foo="bar" |
|
| 127 |
+ --label bar=baz \ |
|
| 128 |
+ redis:3.0.6 |
|
| 129 |
+``` |
|
| 130 |
+ |
|
| 131 |
+For more information about labels, refer to [apply custom |
|
| 132 |
+metadata](../../userguide/labels-custom-metadata.md) |
|
| 133 |
+ |
|
| 134 |
+### Service mode |
|
| 135 |
+ |
|
| 136 |
+Is this a replicated service or a global service. A replicated service runs as |
|
| 137 |
+many tasks as specified, while a global service runs on each active node in the |
|
| 138 |
+swarm. |
|
| 139 |
+ |
|
| 140 |
+The following command creates a "global" service: |
|
| 141 |
+ |
|
| 142 |
+```bash |
|
| 143 |
+$ docker service create --name redis_2 --mode global redis:3.0.6 |
|
| 144 |
+``` |
|
| 145 |
+ |
|
| 146 |
+ |
|
| 147 |
+## Related information |
|
| 148 |
+ |
|
| 149 |
+* [service inspect](service_inspect.md) |
|
| 150 |
+* [service ls](service_ls.md) |
|
| 151 |
+* [service rm](service_rm.md) |
|
| 152 |
+* [service scale](service_scale.md) |
|
| 153 |
+* [service tasks](service_tasks.md) |
|
| 154 |
+* [service update](service_update.md) |
| 0 | 155 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,158 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "service inspect" |
|
| 2 |
+description = "The service inspect command description and usage" |
|
| 3 |
+keywords = ["service, inspect"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+<![end-metadata]--> |
|
| 7 |
+ |
|
| 8 |
+**Warning:** this command is part of the Swarm management feature introduced in Docker 1.12, and might be subject to non backward-compatible changes. |
|
| 9 |
+ |
|
| 10 |
+# service inspect |
|
| 11 |
+ |
|
| 12 |
+```Markdown |
|
| 13 |
+Usage: docker service inspect [OPTIONS] SERVICE [SERVICE...] |
|
| 14 |
+ |
|
| 15 |
+Inspect a service |
|
| 16 |
+ |
|
| 17 |
+Options: |
|
| 18 |
+ -f, --format string Format the output using the given go template |
|
| 19 |
+ --help Print usage |
|
| 20 |
+ -p, --pretty Print the information in a human friendly format. |
|
| 21 |
+``` |
|
| 22 |
+ |
|
| 23 |
+ |
|
| 24 |
+Inspects the specified service. This command has to be run targeting a manager |
|
| 25 |
+node. |
|
| 26 |
+ |
|
| 27 |
+By default, this renders all results in a JSON array. If a format is specified, |
|
| 28 |
+the given template will be executed for each result. |
|
| 29 |
+ |
|
| 30 |
+Go's [text/template](http://golang.org/pkg/text/template/) package |
|
| 31 |
+describes all the details of the format. |
|
| 32 |
+ |
|
| 33 |
+## Examples |
|
| 34 |
+ |
|
| 35 |
+### Inspecting a service by name or ID |
|
| 36 |
+ |
|
| 37 |
+You can inspect a service, either by its *name*, or *ID* |
|
| 38 |
+ |
|
| 39 |
+For example, given the following service; |
|
| 40 |
+ |
|
| 41 |
+```bash |
|
| 42 |
+$ docker service ls |
|
| 43 |
+ID NAME REPLICAS IMAGE COMMAND |
|
| 44 |
+dmu1ept4cxcf redis 3/3 redis:3.0.6 |
|
| 45 |
+``` |
|
| 46 |
+ |
|
| 47 |
+Both `docker service inspect redis`, and `docker service inspect dmu1ept4cxcf` |
|
| 48 |
+produce the same result: |
|
| 49 |
+ |
|
| 50 |
+```bash |
|
| 51 |
+$ docker service inspect redis |
|
| 52 |
+[ |
|
| 53 |
+ {
|
|
| 54 |
+ "ID": "dmu1ept4cxcfe8k8lhtux3ro3", |
|
| 55 |
+ "Version": {
|
|
| 56 |
+ "Index": 12 |
|
| 57 |
+ }, |
|
| 58 |
+ "CreatedAt": "2016-06-17T18:44:02.558012087Z", |
|
| 59 |
+ "UpdatedAt": "2016-06-17T18:44:02.558012087Z", |
|
| 60 |
+ "Spec": {
|
|
| 61 |
+ "Name": "redis", |
|
| 62 |
+ "TaskTemplate": {
|
|
| 63 |
+ "ContainerSpec": {
|
|
| 64 |
+ "Image": "redis:3.0.6" |
|
| 65 |
+ }, |
|
| 66 |
+ "Resources": {
|
|
| 67 |
+ "Limits": {},
|
|
| 68 |
+ "Reservations": {}
|
|
| 69 |
+ }, |
|
| 70 |
+ "RestartPolicy": {
|
|
| 71 |
+ "Condition": "any", |
|
| 72 |
+ "MaxAttempts": 0 |
|
| 73 |
+ }, |
|
| 74 |
+ "Placement": {}
|
|
| 75 |
+ }, |
|
| 76 |
+ "Mode": {
|
|
| 77 |
+ "Replicated": {
|
|
| 78 |
+ "Replicas": 1 |
|
| 79 |
+ } |
|
| 80 |
+ }, |
|
| 81 |
+ "UpdateConfig": {},
|
|
| 82 |
+ "EndpointSpec": {
|
|
| 83 |
+ "Mode": "vip" |
|
| 84 |
+ } |
|
| 85 |
+ }, |
|
| 86 |
+ "Endpoint": {
|
|
| 87 |
+ "Spec": {}
|
|
| 88 |
+ } |
|
| 89 |
+ } |
|
| 90 |
+] |
|
| 91 |
+``` |
|
| 92 |
+ |
|
| 93 |
+```bash |
|
| 94 |
+$ docker service inspect dmu1ept4cxcf |
|
| 95 |
+[ |
|
| 96 |
+ {
|
|
| 97 |
+ "ID": "dmu1ept4cxcfe8k8lhtux3ro3", |
|
| 98 |
+ "Version": {
|
|
| 99 |
+ "Index": 12 |
|
| 100 |
+ }, |
|
| 101 |
+ ... |
|
| 102 |
+ } |
|
| 103 |
+] |
|
| 104 |
+``` |
|
| 105 |
+ |
|
| 106 |
+### Inspect a service using pretty-print |
|
| 107 |
+ |
|
| 108 |
+You can print the inspect output in a human-readable format instead of the default |
|
| 109 |
+JSON output, by using the `--pretty` option: |
|
| 110 |
+ |
|
| 111 |
+```bash |
|
| 112 |
+$ docker service inspect --pretty frontend |
|
| 113 |
+ID: c8wgl7q4ndfd52ni6qftkvnnp |
|
| 114 |
+Name: frontend |
|
| 115 |
+Labels: |
|
| 116 |
+ - org.example.projectname=demo-app |
|
| 117 |
+Mode: REPLICATED |
|
| 118 |
+ Replicas: 5 |
|
| 119 |
+Placement: |
|
| 120 |
+ Strategy: Spread |
|
| 121 |
+UpdateConfig: |
|
| 122 |
+ Parallelism: 0 |
|
| 123 |
+ContainerSpec: |
|
| 124 |
+ Image: nginx:alpine |
|
| 125 |
+Resources: |
|
| 126 |
+Reservations: |
|
| 127 |
+Limits: |
|
| 128 |
+Ports: |
|
| 129 |
+ Name = |
|
| 130 |
+ Protocol = tcp |
|
| 131 |
+ TargetPort = 443 |
|
| 132 |
+ PublishedPort = 4443 |
|
| 133 |
+``` |
|
| 134 |
+ |
|
| 135 |
+ |
|
| 136 |
+### Finding the number of tasks running as part of a service |
|
| 137 |
+ |
|
| 138 |
+The `--format` option can be used to obtain specific information about a |
|
| 139 |
+service. For example, the following command outputs the number of replicas |
|
| 140 |
+of the "redis" service. |
|
| 141 |
+ |
|
| 142 |
+```bash |
|
| 143 |
+$ docker service inspect --format='{{.Spec.Mode.Replicated.Replicas}}' redis
|
|
| 144 |
+10 |
|
| 145 |
+``` |
|
| 146 |
+ |
|
| 147 |
+ |
|
| 148 |
+## Related information |
|
| 149 |
+ |
|
| 150 |
+* [service create](service_create.md) |
|
| 151 |
+* [service ls](service_ls.md) |
|
| 152 |
+* [service rm](service_rm.md) |
|
| 153 |
+* [service scale](service_scale.md) |
|
| 154 |
+* [service tasks](service_tasks.md) |
|
| 155 |
+* [service update](service_update.md) |
| 0 | 156 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,112 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "service ls" |
|
| 2 |
+description = "The service ls command description and usage" |
|
| 3 |
+keywords = ["service, ls"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+<![end-metadata]--> |
|
| 7 |
+ |
|
| 8 |
+**Warning:** this command is part of the Swarm management feature introduced in Docker 1.12, and might be subject to non backward-compatible changes. |
|
| 9 |
+ |
|
| 10 |
+# service ls |
|
| 11 |
+ |
|
| 12 |
+```Markdown |
|
| 13 |
+docker service ls --help |
|
| 14 |
+ |
|
| 15 |
+Usage: docker service ls [OPTIONS] |
|
| 16 |
+ |
|
| 17 |
+List services |
|
| 18 |
+ |
|
| 19 |
+Aliases: |
|
| 20 |
+ ls, list |
|
| 21 |
+ |
|
| 22 |
+Options: |
|
| 23 |
+ -f, --filter value Filter output based on conditions provided |
|
| 24 |
+ --help Print usage |
|
| 25 |
+ -q, --quiet Only display IDs |
|
| 26 |
+``` |
|
| 27 |
+ |
|
| 28 |
+This command when run targeting a manager, lists services are running in the |
|
| 29 |
+swarm. |
|
| 30 |
+ |
|
| 31 |
+On a manager node: |
|
| 32 |
+```bash |
|
| 33 |
+ID NAME REPLICAS IMAGE COMMAND |
|
| 34 |
+c8wgl7q4ndfd frontend 5/5 nginx:alpine |
|
| 35 |
+dmu1ept4cxcf redis 3/3 redis:3.0.6 |
|
| 36 |
+``` |
|
| 37 |
+ |
|
| 38 |
+The `REPLICAS` column shows both the *actual* and *desired* number of tasks for |
|
| 39 |
+the service. |
|
| 40 |
+ |
|
| 41 |
+ |
|
| 42 |
+## Filtering |
|
| 43 |
+ |
|
| 44 |
+The filtering flag (`-f` or `--filter`) format is of "key=value". If there is more |
|
| 45 |
+than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`) |
|
| 46 |
+ |
|
| 47 |
+The currently supported filters are: |
|
| 48 |
+ |
|
| 49 |
+* [id](#id) |
|
| 50 |
+* [label](#label) |
|
| 51 |
+* [name](#name) |
|
| 52 |
+ |
|
| 53 |
+#### ID |
|
| 54 |
+ |
|
| 55 |
+The `id` filter matches all or part of a service's id. |
|
| 56 |
+ |
|
| 57 |
+```bash |
|
| 58 |
+$ docker service ls -f "id=0bcjw" |
|
| 59 |
+ID NAME REPLICAS IMAGE COMMAND |
|
| 60 |
+0bcjwfh8ychr redis 1/1 redis:3.0.6 |
|
| 61 |
+``` |
|
| 62 |
+ |
|
| 63 |
+#### Label |
|
| 64 |
+ |
|
| 65 |
+The `label` filter matches services based on the presence of a `label` alone or |
|
| 66 |
+a `label` and a value. |
|
| 67 |
+ |
|
| 68 |
+The following filter matches all services with a `project` label regardless of |
|
| 69 |
+its value: |
|
| 70 |
+ |
|
| 71 |
+```bash |
|
| 72 |
+$ docker service ls --filter label=project |
|
| 73 |
+ID NAME REPLICAS IMAGE COMMAND |
|
| 74 |
+01sl1rp6nj5u frontend2 1/1 nginx:alpine |
|
| 75 |
+36xvvwwauej0 frontend 5/5 nginx:alpine |
|
| 76 |
+74nzcxxjv6fq backend 3/3 redis:3.0.6 |
|
| 77 |
+``` |
|
| 78 |
+ |
|
| 79 |
+The following filter matches only services with the `project` label with the |
|
| 80 |
+`project-a` value. |
|
| 81 |
+ |
|
| 82 |
+```bash |
|
| 83 |
+$ docker service ls --filter label=project=project-a |
|
| 84 |
+ID NAME REPLICAS IMAGE COMMAND |
|
| 85 |
+36xvvwwauej0 frontend 5/5 nginx:alpine |
|
| 86 |
+74nzcxxjv6fq backend 3/3 redis:3.0.6 |
|
| 87 |
+``` |
|
| 88 |
+ |
|
| 89 |
+ |
|
| 90 |
+#### Name |
|
| 91 |
+ |
|
| 92 |
+The `name` filter matches on all or part of a tasks's name. |
|
| 93 |
+ |
|
| 94 |
+The following filter matches services with a name containing `redis`. |
|
| 95 |
+ |
|
| 96 |
+```bash |
|
| 97 |
+$ docker service ls --filter name=redis |
|
| 98 |
+ID NAME REPLICAS IMAGE COMMAND |
|
| 99 |
+0bcjwfh8ychr redis 1/1 redis:3.0.6 |
|
| 100 |
+``` |
|
| 101 |
+ |
|
| 102 |
+## Related information |
|
| 103 |
+ |
|
| 104 |
+* [service create](service_create.md) |
|
| 105 |
+* [service inspect](service_inspect.md) |
|
| 106 |
+* [service rm](service_rm.md) |
|
| 107 |
+* [service scale](service_scale.md) |
|
| 108 |
+* [service tasks](service_tasks.md) |
|
| 109 |
+* [service update](service_update.md) |
| 0 | 110 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,51 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "service rm" |
|
| 2 |
+description = "The service rm command description and usage" |
|
| 3 |
+keywords = ["service, rm"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+<![end-metadata]--> |
|
| 7 |
+ |
|
| 8 |
+**Warning:** this command is part of the Swarm management feature introduced in Docker 1.12, and might be subject to non backward-compatible changes. |
|
| 9 |
+ |
|
| 10 |
+# service rm |
|
| 11 |
+ |
|
| 12 |
+```Markdown |
|
| 13 |
+Usage: docker service rm [OPTIONS] SERVICE |
|
| 14 |
+ |
|
| 15 |
+Remove a service |
|
| 16 |
+ |
|
| 17 |
+Aliases: |
|
| 18 |
+ rm, remove |
|
| 19 |
+ |
|
| 20 |
+Options: |
|
| 21 |
+ --help Print usage |
|
| 22 |
+``` |
|
| 23 |
+ |
|
| 24 |
+Removes the specified services from the swarm. This command has to be run |
|
| 25 |
+targeting a manager node. |
|
| 26 |
+ |
|
| 27 |
+For example, to remove the redis service: |
|
| 28 |
+ |
|
| 29 |
+```bash |
|
| 30 |
+$ docker service rm redis |
|
| 31 |
+redis |
|
| 32 |
+$ docker service ls |
|
| 33 |
+ID NAME SCALE IMAGE COMMAND |
|
| 34 |
+``` |
|
| 35 |
+ |
|
| 36 |
+> **Warning**: Unlike `docker rm`, this command does not ask for confirmation |
|
| 37 |
+> before removing a running service. |
|
| 38 |
+ |
|
| 39 |
+ |
|
| 40 |
+ |
|
| 41 |
+## Related information |
|
| 42 |
+ |
|
| 43 |
+* [service create](service_create.md) |
|
| 44 |
+* [service inspect](service_inspect.md) |
|
| 45 |
+* [service ls](service_ls.md) |
|
| 46 |
+* [service scale](service_scale.md) |
|
| 47 |
+* [service tasks](service_tasks.md) |
|
| 48 |
+* [service update](service_update.md) |
| 0 | 49 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,79 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "service scale" |
|
| 2 |
+description = "The service scale command description and usage" |
|
| 3 |
+keywords = ["service, scale"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+<![end-metadata]--> |
|
| 7 |
+ |
|
| 8 |
+**Warning:** this command is part of the Swarm management feature introduced in Docker 1.12, and might be subject to non backward-compatible changes. |
|
| 9 |
+ |
|
| 10 |
+# service scale |
|
| 11 |
+ |
|
| 12 |
+ Usage: docker service scale SERVICE=REPLICAS [SERVICE=REPLICAS...] |
|
| 13 |
+ |
|
| 14 |
+ Scale one or multiple services |
|
| 15 |
+ |
|
| 16 |
+ Options: |
|
| 17 |
+ --help Print usage |
|
| 18 |
+ |
|
| 19 |
+ |
|
| 20 |
+## Examples |
|
| 21 |
+ |
|
| 22 |
+### Scale a service |
|
| 23 |
+ |
|
| 24 |
+If you scale a service, you set the *desired* number of replicas. Even though |
|
| 25 |
+the command returns directly, actual scaling of the service may take some time. |
|
| 26 |
+ |
|
| 27 |
+For example, the following command scales the "frontend" service to 50 tasks. |
|
| 28 |
+ |
|
| 29 |
+```bash |
|
| 30 |
+$ docker service scale frontend=50 |
|
| 31 |
+frontend scaled to 50 |
|
| 32 |
+``` |
|
| 33 |
+ |
|
| 34 |
+Directly afterwards, run `docker service ls`, to see the actual number of |
|
| 35 |
+replicas |
|
| 36 |
+ |
|
| 37 |
+```bash |
|
| 38 |
+$ docker service ls --filter name=frontend |
|
| 39 |
+ |
|
| 40 |
+ID NAME REPLICAS IMAGE COMMAND |
|
| 41 |
+3pr5mlvu3fh9 frontend 15/50 nginx:alpine |
|
| 42 |
+``` |
|
| 43 |
+ |
|
| 44 |
+You can also scale a service using the [`docker service update`](service_update.md) |
|
| 45 |
+command. The following commands are therefore equivalent: |
|
| 46 |
+ |
|
| 47 |
+```bash |
|
| 48 |
+$ docker service scale frontend=50 |
|
| 49 |
+$ docker service update --replicas=50 frontend |
|
| 50 |
+``` |
|
| 51 |
+ |
|
| 52 |
+### Scale multiple services |
|
| 53 |
+ |
|
| 54 |
+The `docker service scale` command allows you to set the desired number of |
|
| 55 |
+tasks for multiple services at once. The following example scales both the |
|
| 56 |
+backend and frontend services: |
|
| 57 |
+ |
|
| 58 |
+```bash |
|
| 59 |
+$ docker service scale backend=3 frontend=5 |
|
| 60 |
+backend scaled to 3 |
|
| 61 |
+frontend scaled to 5 |
|
| 62 |
+ |
|
| 63 |
+$ docker service ls |
|
| 64 |
+ID NAME REPLICAS IMAGE COMMAND |
|
| 65 |
+3pr5mlvu3fh9 frontend 5/5 nginx:alpine |
|
| 66 |
+74nzcxxjv6fq backend 3/3 redis:3.0.6 |
|
| 67 |
+``` |
|
| 68 |
+ |
|
| 69 |
+## Related information |
|
| 70 |
+ |
|
| 71 |
+* [service create](service_create.md) |
|
| 72 |
+* [service inspect](service_inspect.md) |
|
| 73 |
+* [service ls](service_ls.md) |
|
| 74 |
+* [service rm](service_rm.md) |
|
| 75 |
+* [service tasks](service_tasks.md) |
|
| 76 |
+* [service update](service_update.md) |
| 0 | 77 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,95 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "service tasks" |
|
| 2 |
+description = "The service tasks command description and usage" |
|
| 3 |
+keywords = ["service, tasks"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+<![end-metadata]--> |
|
| 7 |
+ |
|
| 8 |
+**Warning:** this command is part of the Swarm management feature introduced in Docker 1.12, and might be subject to non backward-compatible changes. |
|
| 9 |
+ |
|
| 10 |
+# service tasks |
|
| 11 |
+ |
|
| 12 |
+```Markdown |
|
| 13 |
+Usage: docker service tasks [OPTIONS] SERVICE |
|
| 14 |
+ |
|
| 15 |
+List the tasks of a service |
|
| 16 |
+ |
|
| 17 |
+Options: |
|
| 18 |
+ -a, --all Display all tasks |
|
| 19 |
+ -f, --filter value Filter output based on conditions provided |
|
| 20 |
+ --help Print usage |
|
| 21 |
+ -n, --no-resolve Do not map IDs to Names |
|
| 22 |
+``` |
|
| 23 |
+ |
|
| 24 |
+Lists the tasks that are running as part of the specified service. This command |
|
| 25 |
+has to be run targeting a manager node. |
|
| 26 |
+ |
|
| 27 |
+ |
|
| 28 |
+## Examples |
|
| 29 |
+ |
|
| 30 |
+### Listing the tasks that are part of a service |
|
| 31 |
+ |
|
| 32 |
+The following command shows all the tasks that are part of the `redis` service: |
|
| 33 |
+ |
|
| 34 |
+```bash |
|
| 35 |
+$ docker service tasks redis |
|
| 36 |
+ID NAME SERVICE IMAGE LAST STATE DESIRED STATE NODE |
|
| 37 |
+0qihejybwf1x5vqi8lgzlgnpq redis.1 redis redis:3.0.6 Running 8 seconds Running manager1 |
|
| 38 |
+bk658fpbex0d57cqcwoe3jthu redis.2 redis redis:3.0.6 Running 9 seconds Running worker2 |
|
| 39 |
+5ls5s5fldaqg37s9pwayjecrf redis.3 redis redis:3.0.6 Running 9 seconds Running worker1 |
|
| 40 |
+8ryt076polmclyihzx67zsssj redis.4 redis redis:3.0.6 Running 9 seconds Running worker1 |
|
| 41 |
+1x0v8yomsncd6sbvfn0ph6ogc redis.5 redis redis:3.0.6 Running 8 seconds Running manager1 |
|
| 42 |
+71v7je3el7rrw0osfywzs0lko redis.6 redis redis:3.0.6 Running 9 seconds Running worker2 |
|
| 43 |
+4l3zm9b7tfr7cedaik8roxq6r redis.7 redis redis:3.0.6 Running 9 seconds Running worker2 |
|
| 44 |
+9tfpyixiy2i74ad9uqmzp1q6o redis.8 redis redis:3.0.6 Running 9 seconds Running worker1 |
|
| 45 |
+3w1wu13yuplna8ri3fx47iwad redis.9 redis redis:3.0.6 Running 8 seconds Running manager1 |
|
| 46 |
+8eaxrb2fqpbnv9x30vr06i6vt redis.10 redis redis:3.0.6 Running 8 seconds Running manager1 |
|
| 47 |
+``` |
|
| 48 |
+ |
|
| 49 |
+ |
|
| 50 |
+## Filtering |
|
| 51 |
+ |
|
| 52 |
+The filtering flag (`-f` or `--filter`) format is a `key=value` pair. If there |
|
| 53 |
+is more than one filter, then pass multiple flags (e.g. `--filter "foo=bar" --filter "bif=baz"`). |
|
| 54 |
+Multiple filter flags are combined as an `OR` filter. For example, |
|
| 55 |
+`-f type=custom -f type=builtin` returns both `custom` and `builtin` networks. |
|
| 56 |
+ |
|
| 57 |
+The currently supported filters are: |
|
| 58 |
+ |
|
| 59 |
+* [id](#id) |
|
| 60 |
+* [name](#name) |
|
| 61 |
+ |
|
| 62 |
+ |
|
| 63 |
+#### ID |
|
| 64 |
+ |
|
| 65 |
+The `id` filter matches on all or a prefix of a task's ID. |
|
| 66 |
+ |
|
| 67 |
+```bash |
|
| 68 |
+$ docker service tasks -f "id=8" redis |
|
| 69 |
+ID NAME SERVICE IMAGE LAST STATE DESIRED STATE NODE |
|
| 70 |
+8ryt076polmclyihzx67zsssj redis.4 redis redis:3.0.6 Running 4 minutes Running worker1 |
|
| 71 |
+8eaxrb2fqpbnv9x30vr06i6vt redis.10 redis redis:3.0.6 Running 4 minutes Running manager1 |
|
| 72 |
+``` |
|
| 73 |
+ |
|
| 74 |
+#### Name |
|
| 75 |
+ |
|
| 76 |
+The `name` filter matches on task names. |
|
| 77 |
+ |
|
| 78 |
+```bash |
|
| 79 |
+$ docker service tasks -f "name=redis.1" redis |
|
| 80 |
+ID NAME SERVICE IMAGE DESIRED STATE LAST STATE NODE |
|
| 81 |
+0qihejybwf1x5vqi8lgzlgnpq redis.1 redis redis:3.0.6 Running Running 8 seconds manager1 |
|
| 82 |
+``` |
|
| 83 |
+ |
|
| 84 |
+ |
|
| 85 |
+## Related information |
|
| 86 |
+ |
|
| 87 |
+* [service create](service_create.md) |
|
| 88 |
+* [service inspect](service_inspect.md) |
|
| 89 |
+* [service ls](service_ls.md) |
|
| 90 |
+* [service rm](service_rm.md) |
|
| 91 |
+* [service scale](service_scale.md) |
|
| 92 |
+* [service update](service_update.md) |
| 0 | 93 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,68 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "service update" |
|
| 2 |
+description = "The service update command description and usage" |
|
| 3 |
+keywords = ["service, update"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+<![end-metadata]--> |
|
| 7 |
+ |
|
| 8 |
+**Warning:** this command is part of the Swarm management feature introduced in Docker 1.12, and might be subject to non backward-compatible changes. |
|
| 9 |
+ |
|
| 10 |
+# service update |
|
| 11 |
+ |
|
| 12 |
+```Markdown |
|
| 13 |
+Usage: docker service update [OPTIONS] SERVICE |
|
| 14 |
+ |
|
| 15 |
+Update a service |
|
| 16 |
+ |
|
| 17 |
+Options: |
|
| 18 |
+ --arg value Service command args (default []) |
|
| 19 |
+ --command value Service command (default []) |
|
| 20 |
+ --constraint value Placement constraints (default []) |
|
| 21 |
+ --endpoint-mode string Endpoint mode(Valid values: VIP, DNSRR) |
|
| 22 |
+ -e, --env value Set environment variables (default []) |
|
| 23 |
+ --help Print usage |
|
| 24 |
+ --image string Service image tag |
|
| 25 |
+ -l, --label value Service labels (default []) |
|
| 26 |
+ --limit-cpu value Limit CPUs (default 0.000) |
|
| 27 |
+ --limit-memory value Limit Memory (default 0 B) |
|
| 28 |
+ --mode string Service mode (replicated or global) (default "replicated") |
|
| 29 |
+ -m, --mount value Attach a mount to the service |
|
| 30 |
+ --name string Service name |
|
| 31 |
+ --network value Network attachments (default []) |
|
| 32 |
+ -p, --publish value Publish a port as a node port (default []) |
|
| 33 |
+ --replicas value Number of tasks (default none) |
|
| 34 |
+ --reserve-cpu value Reserve CPUs (default 0.000) |
|
| 35 |
+ --reserve-memory value Reserve Memory (default 0 B) |
|
| 36 |
+ --restart-condition string Restart when condition is met (none, on_failure, or any) |
|
| 37 |
+ --restart-delay value Delay between restart attempts (default none) |
|
| 38 |
+ --restart-max-attempts value Maximum number of restarts before giving up (default none) |
|
| 39 |
+ --restart-window value Window used to evalulate the restart policy (default none) |
|
| 40 |
+ --stop-grace-period value Time to wait before force killing a container (default none) |
|
| 41 |
+ --update-delay duration Delay between updates |
|
| 42 |
+ --update-parallelism uint Maximum number of tasks updated simultaneously |
|
| 43 |
+ -u, --user string Username or UID |
|
| 44 |
+ -w, --workdir string Working directory inside the container |
|
| 45 |
+``` |
|
| 46 |
+ |
|
| 47 |
+Updates a service as described by the specified parameters. This command has to be run targeting a manager node. |
|
| 48 |
+The parameters are the same as [`docker service create`](service_create.md). Please look at the description there |
|
| 49 |
+for further information. |
|
| 50 |
+ |
|
| 51 |
+## Examples |
|
| 52 |
+ |
|
| 53 |
+### Update a service |
|
| 54 |
+ |
|
| 55 |
+```bash |
|
| 56 |
+$ docker service update --limit-cpu 2 redis |
|
| 57 |
+``` |
|
| 58 |
+ |
|
| 59 |
+## Related information |
|
| 60 |
+ |
|
| 61 |
+* [service create](service_create.md) |
|
| 62 |
+* [service inspect](service_inspect.md) |
|
| 63 |
+* [service tasks](service_tasks.md) |
|
| 64 |
+* [service ls](service_ls.md) |
|
| 65 |
+* [service rm](service_rm.md) |