github.com/flavio/docker@v0.1.3-0.20170117145210-f63d1a6eec47/docs/reference/commandline/service_update.md (about) 1 --- 2 title: "service update" 3 description: "The service update command description and usage" 4 keywords: "service, update" 5 --- 6 7 <!-- This file is maintained within the docker/docker Github 8 repository at https://github.com/docker/docker/. Make all 9 pull requests against that repo. If you see this file in 10 another repository, consider it read-only there, as it will 11 periodically be overwritten by the definitive file. Pull 12 requests which include edits to this file in other repositories 13 will be rejected. 14 --> 15 16 # service update 17 18 ```Markdown 19 Usage: docker service update [OPTIONS] SERVICE 20 21 Update a service 22 23 Options: 24 --args string Service command args 25 --constraint-add list Add or update a placement constraint (default []) 26 --constraint-rm list Remove a constraint (default []) 27 --container-label-add list Add or update a container label (default []) 28 --container-label-rm list Remove a container label by its key (default []) 29 --dns-add list Add or update a custom DNS server (default []) 30 --dns-option-add list Add or update a DNS option (default []) 31 --dns-option-rm list Remove a DNS option (default []) 32 --dns-rm list Remove a custom DNS server (default []) 33 --dns-search-add list Add or update a custom DNS search domain (default []) 34 --dns-search-rm list Remove a DNS search domain (default []) 35 --endpoint-mode string Endpoint mode (vip or dnsrr) 36 --env-add list Add or update an environment variable (default []) 37 --env-rm list Remove an environment variable (default []) 38 --force Force update even if no changes require it 39 --group-add list Add an additional supplementary user group to the container (default []) 40 --group-rm list Remove a previously added supplementary user group from the container (default []) 41 --health-cmd string Command to run to check health 42 --health-interval duration Time between running the check (ns|us|ms|s|m|h) 43 --health-retries int Consecutive failures needed to report unhealthy 44 --health-timeout duration Maximum time to allow one check to run (ns|us|ms|s|m|h) 45 --help Print usage 46 --host-add list Add or update a custom host-to-IP mapping (host:ip) (default []) 47 --host-rm list Remove a custom host-to-IP mapping (host:ip) (default []) 48 --hostname string Container hostname 49 --image string Service image tag 50 --label-add list Add or update a service label (default []) 51 --label-rm list Remove a label by its key (default []) 52 --limit-cpu decimal Limit CPUs (default 0.000) 53 --limit-memory bytes Limit Memory (default 0 B) 54 --log-driver string Logging driver for service 55 --log-opt list Logging driver options (default []) 56 --mount-add mount Add or update a mount on a service 57 --mount-rm list Remove a mount by its target path (default []) 58 --no-healthcheck Disable any container-specified HEALTHCHECK 59 --publish-add port Add or update a published port 60 --publish-rm port Remove a published port by its target port 61 --replicas uint Number of tasks 62 --reserve-cpu decimal Reserve CPUs (default 0.000) 63 --reserve-memory bytes Reserve Memory (default 0 B) 64 --restart-condition string Restart when condition is met (none, on-failure, or any) 65 --restart-delay duration Delay between restart attempts (ns|us|ms|s|m|h) 66 --restart-max-attempts uint Maximum number of restarts before giving up 67 --restart-window duration Window used to evaluate the restart policy (ns|us|ms|s|m|h) 68 --rollback Rollback to previous specification 69 --secret-add secret Add or update a secret on a service 70 --secret-rm list Remove a secret (default []) 71 --stop-grace-period duration Time to wait before force killing a container (ns|us|ms|s|m|h) 72 -t, --tty Allocate a pseudo-TTY 73 --update-delay duration Delay between updates (ns|us|ms|s|m|h) (default 0s) 74 --update-failure-action string Action on update failure (pause|continue) (default "pause") 75 --update-max-failure-ratio float Failure rate to tolerate during an update 76 --update-monitor duration Duration after each task update to monitor for failure (ns|us|ms|s|m|h) (default 0s) 77 --update-parallelism uint Maximum number of tasks updated simultaneously (0 to update all at once) (default 1) 78 -u, --user string Username or UID (format: <name|uid>[:<group|gid>]) 79 --with-registry-auth Send registry authentication details to swarm agents 80 -w, --workdir string Working directory inside the container 81 ``` 82 83 Updates a service as described by the specified parameters. This command has to be run targeting a manager node. 84 The parameters are the same as [`docker service create`](service_create.md). Please look at the description there 85 for further information. 86 87 Normally, updating a service will only cause the service's tasks to be replaced with new ones if a change to the 88 service requires recreating the tasks for it to take effect. For example, only changing the 89 `--update-parallelism` setting will not recreate the tasks, because the individual tasks are not affected by this 90 setting. However, the `--force` flag will cause the tasks to be recreated anyway. This can be used to perform a 91 rolling restart without any changes to the service parameters. 92 93 ## Examples 94 95 ### Update a service 96 97 ```bash 98 $ docker service update --limit-cpu 2 redis 99 ``` 100 101 ### Perform a rolling restart with no parameter changes 102 103 ```bash 104 $ docker service update --force --update-parallelism 1 --update-delay 30s redis 105 ``` 106 107 In this example, the `--force` flag causes the service's tasks to be shut down 108 and replaced with new ones even though none of the other parameters would 109 normally cause that to happen. The `--update-parallelism 1` setting ensures 110 that only one task is replaced at a time (this is the default behavior). The 111 `--update-delay 30s` setting introduces a 30 second delay between tasks, so 112 that the rolling restart happens gradually. 113 114 ### Adding and removing mounts 115 116 Use the `--mount-add` or `--mount-rm` options add or remove a service's bind-mounts 117 or volumes. 118 119 The following example creates a service which mounts the `test-data` volume to 120 `/somewhere`. The next step updates the service to also mount the `other-volume` 121 volume to `/somewhere-else`volume, The last step unmounts the `/somewhere` mount 122 point, effectively removing the `test-data` volume. Each command returns the 123 service name. 124 125 - The `--mount-add` flag takes the same parameters as the `--mount` flag on 126 `service create`. Refer to the [volumes and 127 bind-mounts](service_create.md#volumes-and-bind-mounts-mount) section in the 128 `service create` reference for details. 129 130 - The `--mount-rm` flag takes the `target` path of the mount. 131 132 ```bash 133 $ docker service create \ 134 --name=myservice \ 135 --mount \ 136 type=volume,source=test-data,target=/somewhere \ 137 nginx:alpine \ 138 myservice 139 140 myservice 141 142 $ docker service update \ 143 --mount-add \ 144 type=volume,source=other-volume,target=/somewhere-else \ 145 myservice 146 147 myservice 148 149 $ docker service update --mount-rm /somewhere myservice 150 151 myservice 152 ``` 153 154 ### Adding and removing secrets 155 156 Use the `--secret-add` or `--secret-rm` options add or remove a service's 157 secrets. 158 159 The following example adds a secret named `ssh-2` and removes `ssh-1`: 160 161 ```bash 162 $ docker service update \ 163 --secret-add source=ssh-2,target=ssh-2 \ 164 --secret-rm ssh-1 \ 165 myservice 166 ``` 167 168 ### Update services using templates 169 170 Some flags of `service update` support the use of templating. 171 See [`service create`](./service_create.md#templating) for the reference. 172 173 ## Related information 174 175 * [service create](service_create.md) 176 * [service inspect](service_inspect.md) 177 * [service logs](service_logs.md) 178 * [service ls](service_ls.md) 179 * [service ps](service_ps.md) 180 * [service rm](service_rm.md) 181 * [service scale](service_scale.md)