github.com/pwn-term/docker@v0.0.0-20210616085119-6e977cce2565/cli/man/src/container/update.md (about)

     1  The **docker container update** command dynamically updates container configuration.
     2  You can use this command to prevent containers from consuming too many 
     3  resources from their Docker host.  With a single command, you can place 
     4  limits on a single container or on many. To specify more than one container,
     5  provide space-separated list of container names or IDs.
     6  
     7  With the exception of the **--kernel-memory** option, you can specify these
     8  options on a running or a stopped container. On kernel version older than
     9  4.6, You can only update **--kernel-memory** on a stopped container or on
    10  a running container with kernel memory initialized.
    11  
    12  # OPTIONS
    13  
    14  ## kernel-memory
    15  
    16  Kernel memory limit (format: `<number>[<unit>]`, where unit = b, k, m or g)
    17  
    18  Note that on kernel version older than 4.6, you can not update kernel memory on
    19  a running container if the container is started without kernel memory initialized,
    20  in this case, it can only be updated after it's stopped. The new setting takes
    21  effect when the container is started.
    22  
    23  ## memory
    24  
    25  Memory limit (format: <number><optional unit>, where unit = b, k, m or g)
    26  
    27  Note that the memory should be smaller than the already set swap memory limit.
    28  If you want update a memory limit bigger than the already set swap memory limit,
    29  you should update swap memory limit at the same time. If you don't set swap memory 
    30  limit on docker create/run but only memory limit, the swap memory is double
    31  the memory limit.
    32  
    33  # EXAMPLES
    34  
    35  The following sections illustrate ways to use this command.
    36  
    37  ### Update a container's cpu-shares
    38  
    39  To limit a container's cpu-shares to 512, first identify the container
    40  name or ID. You can use **docker ps** to find these values. You can also
    41  use the ID returned from the **docker run** command.  Then, do the following:
    42  
    43  ```bash
    44  $ docker container update --cpu-shares 512 abebf7571666
    45  ```
    46  
    47  ### Update a container with cpu-shares and memory
    48  
    49  To update multiple resource configurations for multiple containers:
    50  
    51  ```bash
    52  $ docker container update --cpu-shares 512 -m 300M abebf7571666 hopeful_morse
    53  ```
    54  
    55  ### Update a container's kernel memory constraints
    56  
    57  You can update a container's kernel memory limit using the **--kernel-memory**
    58  option. On kernel version older than 4.6, this option can be updated on a
    59  running container only if the container was started with **--kernel-memory**.
    60  If the container was started *without* **--kernel-memory** you need to stop
    61  the container before updating kernel memory.
    62  
    63  NOTE: The **--kernel-memory** option has been deprecated since Docker 20.10.
    64  
    65  For example, if you started a container with this command:
    66  
    67  ```bash
    68  $ docker run -dit --name test --kernel-memory 50M ubuntu bash
    69  ```
    70  
    71  You can update kernel memory while the container is running:
    72  
    73  ```bash
    74  $ docker container update --kernel-memory 80M test
    75  ```
    76  
    77  If you started a container *without* kernel memory initialized:
    78  
    79  ```bash
    80  $ docker run -dit --name test2 --memory 300M ubuntu bash
    81  ```
    82  
    83  Update kernel memory of running container `test2` will fail. You need to stop
    84  the container before updating the **--kernel-memory** setting. The next time you
    85  start it, the container uses the new value.
    86  
    87  Kernel version newer than (include) 4.6 does not have this limitation, you
    88  can use `--kernel-memory` the same way as other options.
    89  
    90  ### Update a container's restart policy
    91  
    92  You can change a container's restart policy on a running container. The new
    93  restart policy takes effect instantly after you run `docker container update` on a
    94  container.
    95  
    96  To update restart policy for one or more containers:
    97  
    98  ```bash
    99  $ docker container update --restart=on-failure:3 abebf7571666 hopeful_morse
   100  ```
   101  
   102  Note that if the container is started with "--rm" flag, you cannot update the restart
   103  policy for it. The `AutoRemove` and `RestartPolicy` are mutually exclusive for the
   104  container.