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