YouTip LogoYouTip

Docker Update Command

Docker update command | \\n \\n\\n
\\n
\\n

--

\\n \\n
\\n
\\n
\\n

Docker Tutorial

\\n \\n

Contents

\\n \\n
\\n

Docker Installation

\\n \\n
\\n
\\n

Docker Usage

\\n
    \\n
  • Docker Hello World
  • \\n
  • Docker Container Usage
  • \\n
  • Docker Image Usage
  • docker update  CONTAINER [CONTAINER...]

    Common Parameters

    \\n
      \\n
    • CONTAINER: The container name or container ID for which to update resource limits. You can specify one or more containers.
    • \\n
    • OPTIONS: Used to specify the resource limits that need to be updated.
    • \\n
    \\n

    Common Options OPTIONS:

    \\n
      \\n
    1. --memory, -m: Set the memory limit for the container.\\n
        \\n
      • Format:
      • \\n
      \\n
    2. \\n
    <size>[<unit>]\\n
  • For example:500m、2g etc.
  • \\n
\\n
docker update -m 2g my_container
\\n
  • --memory-swap: Sets the total limit for the container's memory and swap space. If set to `-1`, it means no limit on swap space.\\n
      \\n
    • Format:<size>[<unit>],such as 2g,or `-1` Means no limit.
    • \\n
    \\n
    docker update --memory-swap 3g my_container
  • \\n
  • --cpu-shares: Sets the CPU priority of the container, relative value. Default is `1024`, larger values indicate higher priority.\\n
      \\n
    • This option does not directly limit the CPU usage of the container, but controls the priority of CPU resource allocation.
    • \\n
    docker update --cpu-shares 2048 my_container
  • \\n
  • --cpus: Set the number of CPU cores used by the container. This option can limit the maximum number of CPU cores the container can use.\\n
      \\n
    • Format:<number>, for example: `1.5` indicates a maximum usage of 1.5 CPU cores.
    • \\n
    docker update --cpus 2 my_container
  • \\n
  • --cpu-period: Sets the CPU period. Used in conjunction with `--cpu-quota` to limit the container's CPU usage. The unit is microseconds (default: `100000` microseconds = 100ms).
    docker update --cpu-period 50000 my_container
  • \\n
  • --cpu-quota: Sets the maximum amount of CPU time the container can use per period. The unit is microseconds. Must be used in conjunction with `--cpu-period`.
    docker update --cpu-quota 25000 my_container
  • \\n
  • --blkio-weight: Sets the block I/O weight (range: `10` to `1000`), indicating the container's priority for disk I/O operations. The default value is `500`.
    docker update --blkio-weight 800 my_container
  • \\n
  • --pids-limit: Sets the maximum number of processes the container can use.\\n
      \\n
    • Format:<number>,For example:`100`。
    • \\n
    \\n
    docker update --pids-limit 200 my_container
  • \\n
  • --restart: Set the container restart policy (`no`, `on-failure`, `always`, `unless-stopped`).\\n
    docker update --restart always my_container
  • \\n \\n

    Example

    \\n
      \\n
    1. Update the container's memory limit:
      docker update -m 2g my_container
      This command updates the memory limit of my_container to 2GB.\\n
    2. \\n
    3. Set CPU core limit:\\n
      docker update --cpus 1.5 my_container
      This command limits my_container to a maximum of 1.5 CPU cores.\\n
    4. \\n
    5. Update the container's CPU weight:
      docker update --cpu-shares 1024 my_container
      This command sets the container's CPU weight to 1024, which is the default value.\\n
    6. \\n
    7. Update the container's block I/O weight:
      docker update --blkio-weight 700 my_container
      This command sets the container's disk I/O weight to 700, with the weight ranging from 10 to 1000.\\n
    8. \\n
    \\n

    Limitations

    \\n
      \\n
    • The `docker update` command takes effect immediately, but it does not affect the applications running inside the container; the container continues to run.
    • \\n
    • It only supports adjusting the container's resource limits and cannot modify other container configurations (such as environment variables, port mappings, etc.).
    • \\n
    \\n Image 4: Docker Command Reference\\n
    \\n
    \\n
    ← C Standard Library Stdbool HPython Scrapy β†’