github.com/endophage/docker@v1.4.2-0.20161027011718-242853499895/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 value             Add or update placement constraints (default [])
    26        --constraint-rm value              Remove a constraint (default [])
    27        --container-label-add value        Add or update container labels (default [])
    28        --container-label-rm value         Remove a container label by its key (default [])
    29        --endpoint-mode string             Endpoint mode (vip or dnsrr)
    30        --env-add value                    Add or update environment variables (default [])
    31        --env-rm value                     Remove an environment variable (default [])
    32        --force                            Force update even if no changes require it
    33        --group-add value                  Add additional user groups to the container (default [])
    34        --group-rm value                   Remove previously added user groups from the container (default [])
    35        --help                             Print usage
    36        --image string                     Service image tag
    37        --label-add value                  Add or update service labels (default [])
    38        --label-rm value                   Remove a label by its key (default [])
    39        --limit-cpu value                  Limit CPUs (default 0.000)
    40        --limit-memory value               Limit Memory (default 0 B)
    41        --log-driver string                Logging driver for service
    42        --log-opt value                    Logging driver options (default [])
    43        --mount-add value                  Add or update a mount on a service
    44        --mount-rm value                   Remove a mount by its target path (default [])
    45        --name string                      Service name
    46        --publish-add value                Add or update a published port (default [])
    47        --publish-rm value                 Remove a published port by its target port (default [])
    48        --replicas value                   Number of tasks (default none)
    49        --reserve-cpu value                Reserve CPUs (default 0.000)
    50        --reserve-memory value             Reserve Memory (default 0 B)
    51        --restart-condition string         Restart when condition is met (none, on-failure, or any)
    52        --restart-delay value              Delay between restart attempts (default none)
    53        --restart-max-attempts value       Maximum number of restarts before giving up (default none)
    54        --restart-window value             Window used to evaluate the restart policy (default none)
    55        --rollback                         Rollback to previous specification
    56        --stop-grace-period value          Time to wait before force killing a container (default none)
    57        --update-delay duration            Delay between updates
    58        --update-failure-action string     Action on update failure (pause|continue) (default "pause")
    59        --update-max-failure-ratio value   Failure rate to tolerate during an update
    60        --update-monitor duration          Duration after each task update to monitor for failure (default 0s)
    61        --update-parallelism uint          Maximum number of tasks updated simultaneously (0 to update all at once) (default 1)
    62    -u, --user string                      Username or UID (format: <name|uid>[:<group|gid>])
    63        --with-registry-auth               Send registry authentication details to Swarm agents
    64    -w, --workdir string                   Working directory inside the container
    65  ```
    66  
    67  Updates a service as described by the specified parameters. This command has to be run targeting a manager node.
    68  The parameters are the same as [`docker service create`](service_create.md). Please look at the description there
    69  for further information.
    70  
    71  Normally, updating a service will only cause the service's tasks to be replaced with new ones if a change to the
    72  service requires recreating the tasks for it to take effect. For example, only changing the
    73  `--update-parallelism` setting will not recreate the tasks, because the individual tasks are not affected by this
    74  setting. However, the `--force` flag will cause the tasks to be recreated anyway. This can be used to perform a
    75  rolling restart without any changes to the service parameters.
    76  
    77  ## Examples
    78  
    79  ### Update a service
    80  
    81  ```bash
    82  $ docker service update --limit-cpu 2 redis
    83  ```
    84  
    85  ### Perform a rolling restart with no parameter changes
    86  
    87  ```bash
    88  $ docker service update --force --update-parallelism 1 --update-delay 30s redis
    89  ```
    90  
    91  In this example, the `--force` flag causes the service's tasks to be shut down
    92  and replaced with new ones even though none of the other parameters would
    93  normally cause that to happen. The `--update-parallelism 1` setting ensures
    94  that only one task is replaced at a time (this is the default behavior). The
    95  `--update-delay 30s` setting introduces a 30 second delay between tasks, so
    96  that the rolling restart happens gradually.
    97  
    98  ### Adding and removing mounts
    99  
   100  Use the `--mount-add` or `--mount-rm` options add or remove a service's bind-mounts
   101  or volumes.
   102  
   103  The following example creates a service which mounts the `test-data` volume to
   104  `/somewhere`. The next step updates the service to also mount the `other-volume`
   105  volume to `/somewhere-else`volume, The last step unmounts the `/somewhere` mount
   106  point, effectively removing the `test-data` volume. Each command returns the
   107  service name.
   108  
   109  - The `--mount-add` flag takes the same parameters as the `--mount` flag on
   110    `service create`. Refer to the [volumes and
   111    bind-mounts](service_create.md#volumes-and-bind-mounts-mount) section in the
   112    `service create` reference for details.
   113  
   114  - The `--mount-rm` flag takes the `target` path of the mount.
   115  
   116  ```bash
   117  $ docker service create \
   118      --name=myservice \
   119      --mount \
   120        type=volume,source=test-data,target=/somewhere \
   121      nginx:alpine \
   122      myservice
   123  
   124  myservice
   125  
   126  $ docker service update \
   127      --mount-add \
   128        type=volume,source=other-volume,target=/somewhere-else \
   129      myservice
   130  
   131  myservice
   132  
   133  $ docker service update --mount-rm /somewhere myservice
   134  
   135  myservice
   136  ```
   137  
   138  ## Related information
   139  
   140  * [service create](service_create.md)
   141  * [service inspect](service_inspect.md)
   142  * [service ps](service_ps.md)
   143  * [service ls](service_ls.md)
   144  * [service rm](service_rm.md)