2.6 KiB
datafolder | datafile | title |
---|---|---|
engine-cli | docker_service_update | docker service update |
{% include cli.md %}
Examples
Update a service
$ docker service update --limit-cpu 2 redis
Perform a rolling restart with no parameter changes
$ 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.
Adding and removing 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 onservice create
. Refer to the volumes and bind-mounts section in theservice create
reference for details. -
The
--mount-rm
flag takes thetarget
path of the mount.
$ 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
Adding and removing 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
:
$ 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
for the reference.