Files
docker-docs/_data/engine-cli/docker_service_update.yaml
Misty Stanley-Jones f247ad1863 Update cli ref YAML files (#2789)
* Update cli ref YAML files

* Fix typo

* Backport fixes to the service_create tables
2017-04-14 12:04:35 -07:00

251 lines
8.2 KiB
YAML

command: docker service update
short: Update a service
long: |-
Updates a service as described by the specified parameters. This command has to be run targeting a manager node.
The parameters are the same as [`docker service create`](service_create.md). Please look at the description there
for further information.
Normally, updating a service will only cause the service's tasks to be replaced with new ones if a change to the
service requires recreating the tasks for it to take effect. For example, only changing the
`--update-parallelism` setting will not recreate the tasks, because the individual tasks are not affected by this
setting. However, the `--force` flag will cause the tasks to be recreated anyway. This can be used to perform a
rolling restart without any changes to the service parameters.
usage: docker service update [OPTIONS] SERVICE
pname: docker service
plink: docker_service.yaml
options:
- option: args
description: Service command args
- option: constraint-add
default_value: '[]'
description: Add or update a placement constraint
- option: constraint-rm
default_value: '[]'
description: Remove a constraint
- option: container-label-add
default_value: '[]'
description: Add or update a container label
- option: container-label-rm
default_value: '[]'
description: Remove a container label by its key
- option: dns-add
default_value: '[]'
description: Add or update a custom DNS server
- option: dns-option-add
default_value: '[]'
description: Add or update a DNS option
- option: dns-option-rm
default_value: '[]'
description: Remove a DNS option
- option: dns-rm
default_value: '[]'
description: Remove a custom DNS server
- option: dns-search-add
default_value: '[]'
description: Add or update a custom DNS search domain
- option: dns-search-rm
default_value: '[]'
description: Remove a DNS search domain
- option: endpoint-mode
description: Endpoint mode (vip or dnsrr)
- option: env-add
default_value: '[]'
description: Add or update an environment variable
- option: env-rm
default_value: '[]'
description: Remove an environment variable
- option: force
default_value: "false"
description: Force update even if no changes require it
- option: group-add
default_value: '[]'
description: Add an additional supplementary user group to the container
- option: group-rm
default_value: '[]'
description: |
Remove a previously added supplementary user group from the container
- option: health-cmd
description: Command to run to check health
- option: health-interval
description: Time between running the check (ns|us|ms|s|m|h)
- option: health-retries
default_value: "0"
description: Consecutive failures needed to report unhealthy
- option: health-timeout
description: Maximum time to allow one check to run (ns|us|ms|s|m|h)
- option: host-add
default_value: '[]'
description: Add or update a custom host-to-IP mapping (host:ip)
- option: host-rm
default_value: '[]'
description: Remove a custom host-to-IP mapping (host:ip)
- option: hostname
description: Container hostname
- option: image
description: Service image tag
- option: label-add
default_value: '[]'
description: Add or update a service label
- option: label-rm
default_value: '[]'
description: Remove a label by its key
- option: limit-cpu
default_value: "0.000"
description: Limit CPUs
- option: limit-memory
default_value: 0 B
description: Limit Memory
- option: log-driver
description: Logging driver for service
- option: log-opt
default_value: '[]'
description: Logging driver options
- option: mount-add
description: Add or update a mount on a service
- option: mount-rm
default_value: '[]'
description: Remove a mount by its target path
- option: no-healthcheck
default_value: "false"
description: Disable any container-specified HEALTHCHECK
- option: publish-add
description: Add or update a published port
- option: publish-rm
description: Remove a published port by its target port
- option: replicas
description: Number of tasks
- option: reserve-cpu
default_value: "0.000"
description: Reserve CPUs
- option: reserve-memory
default_value: 0 B
description: Reserve Memory
- option: restart-condition
description: Restart when condition is met (none, on-failure, or any)
- option: restart-delay
description: Delay between restart attempts (ns|us|ms|s|m|h)
- option: restart-max-attempts
description: Maximum number of restarts before giving up
- option: restart-window
description: Window used to evaluate the restart policy (ns|us|ms|s|m|h)
- option: rollback
default_value: "false"
description: Rollback to previous specification
- option: secret-add
description: Add or update a secret on a service
- option: secret-rm
default_value: '[]'
description: Remove a secret
- option: stop-grace-period
description: |
Time to wait before force killing a container (ns|us|ms|s|m|h)
- option: tty
shorthand: t
default_value: "false"
description: Allocate a pseudo-TTY
- option: update-delay
default_value: 0s
description: Delay between updates (ns|us|ms|s|m|h) (default 0s)
- option: update-failure-action
default_value: pause
description: Action on update failure (pause|continue)
- option: update-max-failure-ratio
default_value: "0"
description: Failure rate to tolerate during an update
- option: update-monitor
default_value: 0s
description: |
Duration after each task update to monitor for failure (ns|us|ms|s|m|h) (default 0s)
- option: update-parallelism
default_value: "1"
description: |
Maximum number of tasks updated simultaneously (0 to update all at once)
- option: user
shorthand: u
description: 'Username or UID (format: <name|uid>[:<group|gid>])'
- option: with-registry-auth
default_value: "false"
description: Send registry authentication details to swarm agents
- option: workdir
shorthand: w
description: Working directory inside the container
examples: |-
### Update a service
```bash
$ docker service update --limit-cpu 2 redis
```
### Perform a rolling restart with no parameter changes
```bash
$ docker service update --force --update-parallelism 1 --update-delay 30s redis
```
In this example, the `--force` flag causes the service's tasks to be shut down
and replaced with new ones even though none of the other parameters would
normally cause that to happen. The `--update-parallelism 1` setting ensures
that only one task is replaced at a time (this is the default behavior). The
`--update-delay 30s` setting introduces a 30 second delay between tasks, so
that the rolling restart happens gradually.
### Add or remove mounts
Use the `--mount-add` or `--mount-rm` options add or remove a service's bind-mounts
or volumes.
The following example creates a service which mounts the `test-data` volume to
`/somewhere`. The next step updates the service to also mount the `other-volume`
volume to `/somewhere-else`volume, The last step unmounts the `/somewhere` mount
point, effectively removing the `test-data` volume. Each command returns the
service name.
- The `--mount-add` flag takes the same parameters as the `--mount` flag on
`service create`. Refer to the [volumes and
bind-mounts](service_create.md#volumes-and-bind-mounts-mount) section in the
`service create` reference for details.
- The `--mount-rm` flag takes the `target` path of the mount.
```bash
$ docker service create \
--name=myservice \
--mount \
type=volume,source=test-data,target=/somewhere \
nginx:alpine \
myservice
myservice
$ docker service update \
--mount-add \
type=volume,source=other-volume,target=/somewhere-else \
myservice
myservice
$ docker service update --mount-rm /somewhere myservice
myservice
```
### Add or remove secrets
Use the `--secret-add` or `--secret-rm` options add or remove a service's
secrets.
The following example adds a secret named `ssh-2` and removes `ssh-1`:
```bash
$ docker service update \
--secret-add source=ssh-2,target=ssh-2 \
--secret-rm ssh-1 \
myservice
```
### Update services using templates
Some flags of `service update` support the use of templating.
See [`service create`](./service_create.md#templating) for the reference.