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: config-add description: Add or update a config file on a service - option: config-rm description: Remove a configuration file - option: constraint-add description: Add or update a placement constraint - option: constraint-rm description: Remove a constraint - option: container-label-add description: Add or update a container label - option: container-label-rm description: Remove a container label by its key - option: credential-spec description: Credential spec for managed service account (Windows only) - option: detach shorthand: d default_value: "true" description: | Exit immediately instead of waiting for the service to converge - option: dns-add description: Add or update a custom DNS server - option: dns-option-add description: Add or update a DNS option - option: dns-option-rm description: Remove a DNS option - option: dns-rm description: Remove a custom DNS server - option: dns-search-add description: Add or update a custom DNS search domain - option: dns-search-rm description: Remove a DNS search domain - option: endpoint-mode description: Endpoint mode (vip or dnsrr) - option: entrypoint description: Overwrite the default ENTRYPOINT of the image - option: env-add description: Add or update an environment variable - option: env-rm description: Remove an environment variable - option: force default_value: "false" description: Force update even if no changes require it - option: group-add description: Add an additional supplementary user group to the container - option: group-rm 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 (ms|s|m|h) - option: health-retries default_value: "0" description: Consecutive failures needed to report unhealthy - option: health-start-period description: | Start period for the container to initialize before counting retries towards unstable (ms|s|m|h) - option: health-timeout description: Maximum time to allow one check to run (ms|s|m|h) - option: host-add description: Add or update a custom host-to-IP mapping (host:ip) - option: host-rm description: Remove a custom host-to-IP mapping (host:ip) - option: hostname description: Container hostname - option: image description: Service image tag - option: label-add description: Add or update a service label - option: label-rm description: Remove a label by its key - option: limit-cpu description: Limit CPUs - option: limit-memory default_value: "0" description: Limit Memory - option: log-driver description: Logging driver for service - option: log-opt description: Logging driver options - option: mount-add description: Add or update a mount on a service - option: mount-rm description: Remove a mount by its target path - option: network-add description: Add a network - option: network-rm description: Remove a network - option: no-healthcheck default_value: "false" description: Disable any container-specified HEALTHCHECK - option: no-resolve-image default_value: "false" description: | Do not query the registry to resolve image digest and supported platforms - option: placement-pref-add description: Add a placement preference - option: placement-pref-rm description: Remove a placement preference - option: publish-add description: Add or update a published port - option: publish-rm description: Remove a published port by its target port - option: quiet shorthand: q default_value: "false" description: Suppress progress output - option: read-only default_value: "false" description: Mount the container's root filesystem as read only - option: replicas description: Number of tasks - option: reserve-cpu description: Reserve CPUs - option: reserve-memory default_value: "0" description: Reserve Memory - option: restart-condition description: Restart when condition is met ("none"|"on-failure"|"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: rollback-delay default_value: 0s description: Delay between task rollbacks (ns|us|ms|s|m|h) - option: rollback-failure-action description: Action on rollback failure ("pause"|"continue") - option: rollback-max-failure-ratio default_value: "0" description: Failure rate to tolerate during a rollback - option: rollback-monitor default_value: 0s description: | Duration after each task rollback to monitor for failure (ns|us|ms|s|m|h) - option: rollback-order description: Rollback order ("start-first"|"stop-first") - option: rollback-parallelism default_value: "0" description: | Maximum number of tasks rolled back simultaneously (0 to roll back all at once) - option: secret-add description: Add or update a secret on a service - option: secret-rm description: Remove a secret - option: stop-grace-period description: | Time to wait before force killing a container (ns|us|ms|s|m|h) - option: stop-signal description: Signal to stop the container - 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) - option: update-failure-action description: Action on update failure ("pause"|"continue"|"rollback") - 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) - option: update-order description: Update order ("start-first"|"stop-first") - option: update-parallelism default_value: "0" description: | Maximum number of tasks updated simultaneously (0 to update all at once) - option: user shorthand: u description: 'Username or UID (format: [:])' - 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\nServices can also be set up to roll back to the previous version automatically\nwhen an update fails. To set up a service for automatic rollback, use\n`--update-failure-action=rollback`. A rollback will be triggered if the fraction\nof the tasks which failed to update successfully exceeds the value given with\n`--update-max-failure-ratio`.\n\nThe rate, parallelism, and other parameters of a rollback operation are\ndetermined by the values passed with the following flags:\n\n- `--rollback-delay`\n- `--rollback-failure-action`\n- `--rollback-max-failure-ratio`\n- `--rollback-monitor`\n- `--rollback-parallelism`\n\nFor example, a service set up with `--update-parallelism 1 --rollback-parallelism 3`\nwill update one task at a time during a normal update, but during a rollback, 3\ntasks at a time will get rolled back. These rollback parameters are respected both\nduring automatic rollbacks and for rollbacks initiated manually using `--rollback`.\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."