mirror of https://github.com/docker/docs.git
214 lines
9.3 KiB
YAML
214 lines
9.3 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\n\n```bash\n$ docker service update --limit-cpu 2
|
|
redis\n```\n\n### Perform a rolling restart with no parameter changes\n\n```bash\n$
|
|
docker service update --force --update-parallelism 1 --update-delay 30s redis\n```\n\nIn
|
|
this example, the `--force` flag causes the service's tasks to be shut down\nand
|
|
replaced with new ones even though none of the other parameters would\nnormally
|
|
cause that to happen. The `--update-parallelism 1` setting ensures\nthat only one
|
|
task is replaced at a time (this is the default behavior). The\n`--update-delay
|
|
30s` setting introduces a 30 second delay between tasks, so\nthat the rolling restart
|
|
happens gradually.\n\n### Add or remove mounts\n\nUse the `--mount-add` or `--mount-rm`
|
|
options add or remove a service's bind-mounts\nor volumes.\n\nThe following example
|
|
creates a service which mounts the `test-data` volume to\n`/somewhere`. The next
|
|
step updates the service to also mount the `other-volume`\nvolume to `/somewhere-else`volume,
|
|
The last step unmounts the `/somewhere` mount\npoint, effectively removing the `test-data`
|
|
volume. Each command returns the\nservice name.\n\n- The `--mount-add` flag takes
|
|
the same parameters as the `--mount` flag on\n `service create`. Refer to the [volumes
|
|
and\n bind-mounts](service_create.md#volumes-and-bind-mounts-mount) section in
|
|
the\n `service create` reference for details.\n\n- The `--mount-rm` flag takes
|
|
the `target` path of the mount.\n\n```bash\n$ docker service create \\\n --name=myservice
|
|
\\\n --mount \\\n type=volume,source=test-data,target=/somewhere \\\n nginx:alpine
|
|
\\\n myservice\n\nmyservice\n\n$ docker service update \\\n --mount-add \\\n
|
|
\ type=volume,source=other-volume,target=/somewhere-else \\\n myservice\n\nmyservice\n\n$
|
|
docker service update --mount-rm /somewhere myservice\n\nmyservice\n```\n\n### Rolling
|
|
back to the previous version of a service \n\nUse the `--rollback` option to roll
|
|
back to the previous version of the service. \n\nThis will revert the service to
|
|
the configuration that was in place before the most recent `docker service update`
|
|
command.\n\nThe following example updates the number of replicas for the service
|
|
from 4 to 5, and then rolls back to the previous configuration.\n\n```bash\n$ docker
|
|
service update --replicas=5 web\n\nweb\n\n$ docker service ls\n\nID NAME
|
|
\ MODE REPLICAS IMAGE\n80bvrzp6vxf3 web replicated 0/5 nginx:alpine\n\n```\nRoll
|
|
back the `web` service... \n\n```bash\n$ docker service update --rollback web\n\nweb\n\n$
|
|
docker service ls\n\nID NAME MODE REPLICAS IMAGE\n80bvrzp6vxf3
|
|
\ web replicated 0/4 nginx:alpine\n\n```\n\nOther options can be combined
|
|
with `--rollback` as well, for example, `--update-delay 0s` to execute the rollback
|
|
without a delay between tasks:\n\n```bash\n$ docker service update \\\n --rollback
|
|
\\\n --update-delay 0s\n web\n\nweb\n\n```\n\n### Add or remove secrets\n\nUse
|
|
the `--secret-add` or `--secret-rm` options add or remove a service's\nsecrets.\n\nThe
|
|
following example adds a secret named `ssh-2` and removes `ssh-1`:\n\n```bash\n$
|
|
docker service update \\\n --secret-add source=ssh-2,target=ssh-2 \\\n --secret-rm
|
|
ssh-1 \\\n myservice\n```\n\n### Update services using templates\n\nSome flags
|
|
of `service update` support the use of templating.\nSee [`service create`](./service_create.md#templating)
|
|
for the reference."
|
|
|