github.com/AliyunContainerService/cli@v0.0.0-20181009023821-814ced4b30d0/docs/reference/commandline/update.md (about)

     1  ---
     2  title: "update"
     3  description: "The update command description and usage"
     4  keywords: "resources, update, dynamically"
     5  ---
     6  
     7  <!-- This file is maintained within the docker/cli GitHub
     8       repository at https://github.com/docker/cli/. 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  ## update
    17  
    18  ```markdown
    19  Usage:  docker update [OPTIONS] CONTAINER [CONTAINER...]
    20  
    21  Update configuration of one or more containers
    22  
    23  Options:
    24        --blkio-weight uint16         Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0)
    25        --cpu-period int              Limit CPU CFS (Completely Fair Scheduler) period
    26        --cpu-quota int               Limit CPU CFS (Completely Fair Scheduler) quota
    27        --cpu-rt-period int           Limit the CPU real-time period in microseconds
    28        --cpu-rt-runtime int          Limit the CPU real-time runtime in microseconds
    29    -c, --cpu-shares int              CPU shares (relative weight)
    30        --cpus decimal                Number of CPUs (default 0.000)
    31        --cpuset-cpus string          CPUs in which to allow execution (0-3, 0,1)
    32        --cpuset-mems string          MEMs in which to allow execution (0-3, 0,1)
    33        --help                        Print usage
    34        --kernel-memory string        Kernel memory limit
    35    -m, --memory string               Memory limit
    36        --memory-reservation string   Memory soft limit
    37        --memory-swap string          Swap limit equal to memory plus swap: '-1' to enable unlimited swap
    38        --restart string              Restart policy to apply when a container exits
    39  ```
    40  
    41  ## Description
    42  
    43  The `docker update` command dynamically updates container configuration.
    44  You can use this command to prevent containers from consuming too many
    45  resources from their Docker host.  With a single command, you can place
    46  limits on a single container or on many. To specify more than one container,
    47  provide space-separated list of container names or IDs.
    48  
    49  With the exception of the `--kernel-memory` option, you can specify these
    50  options on a running or a stopped container. On kernel version older than
    51  4.6, you can only update `--kernel-memory` on a stopped container or on
    52  a running container with kernel memory initialized.
    53  
    54  > **Warning**: The `docker update` and `docker container update` commands are
    55  > not supported for Windows containers.
    56  {: .warning }
    57  
    58  ## Examples
    59  
    60  The following sections illustrate ways to use this command.
    61  
    62  ### Update a container's cpu-shares
    63  
    64  To limit a container's cpu-shares to 512, first identify the container
    65  name or ID. You can use `docker ps` to find these values. You can also
    66  use the ID returned from the `docker run` command.  Then, do the following:
    67  
    68  ```bash
    69  $ docker update --cpu-shares 512 abebf7571666
    70  ```
    71  
    72  ### Update a container with cpu-shares and memory
    73  
    74  To update multiple resource configurations for multiple containers:
    75  
    76  ```bash
    77  $ docker update --cpu-shares 512 -m 300M abebf7571666 hopeful_morse
    78  ```
    79  
    80  ### Update a container's kernel memory constraints
    81  
    82  You can update a container's kernel memory limit using the `--kernel-memory`
    83  option. On kernel version older than 4.6, this option can be updated on a
    84  running container only if the container was started with `--kernel-memory`.
    85  If the container was started *without* `--kernel-memory` you need to stop
    86  the container before updating kernel memory.
    87  
    88  For example, if you started a container with this command:
    89  
    90  ```bash
    91  $ docker run -dit --name test --kernel-memory 50M ubuntu bash
    92  ```
    93  
    94  You can update kernel memory while the container is running:
    95  
    96  ```bash
    97  $ docker update --kernel-memory 80M test
    98  ```
    99  
   100  If you started a container *without* kernel memory initialized:
   101  
   102  ```bash
   103  $ docker run -dit --name test2 --memory 300M ubuntu bash
   104  ```
   105  
   106  Update kernel memory of running container `test2` will fail. You need to stop
   107  the container before updating the `--kernel-memory` setting. The next time you
   108  start it, the container uses the new value.
   109  
   110  Kernel version newer than (include) 4.6 does not have this limitation, you
   111  can use `--kernel-memory` the same way as other options.
   112  
   113  ### Update a container's restart policy
   114  
   115  You can change a container's restart policy on a running container. The new
   116  restart policy takes effect instantly after you run `docker update` on a
   117  container.
   118  
   119  To update restart policy for one or more containers:
   120  
   121  ```bash
   122  $ docker update --restart=on-failure:3 abebf7571666 hopeful_morse
   123  ```
   124  
   125  Note that if the container is started with "--rm" flag, you cannot update the restart
   126  policy for it. The `AutoRemove` and `RestartPolicy` are mutually exclusive for the
   127  container.