如何在运行时更改分配给容器的资源?

job*_*bin 7 resources docker

我知道我可以限制分配到一个容器在使用泊坞窗与供应的资源-c-m标志的CPU和内存.

但是,有没有办法可以动态地(在配置它们之后)将这些分配的资源更改为容器,而无需使用更改的资源重新部署相同的容器?

Alv*_*ndo 21

当时(Docker v1.11.1)有命令docker update(查看文档).有了这个,您可以动态更改分配的资源.

Usage:  docker update [OPTIONS] CONTAINER [CONTAINER...]

Update configuration of one or more containers

  --blkio-weight          Block IO (relative weight), between 10 and 1000
  --cpu-shares            CPU shares (relative weight)
  --cpu-period            Limit CPU CFS (Completely Fair Scheduler) period
  --cpu-quota             Limit CPU CFS (Completely Fair Scheduler) quota
  --cpuset-cpus           CPUs in which to allow execution (0-3, 0,1)
  --cpuset-mems           MEMs in which to allow execution (0-3, 0,1)
  --help                  Print usage
  --kernel-memory         Kernel memory limit
  -m, --memory            Memory limit
  --memory-reservation    Memory soft limit
  --memory-swap           Swap limit equal to memory plus swap: '-1' to enable unlimited swap
  --restart               Restart policy to apply when a container exits
Run Code Online (Sandbox Code Playgroud)


Sve*_*eit 3

目前还没有 - 但希望看到有人实现它: https: //github.com/docker/docker/issues/6323

  • 现已实施。请参阅https://docs.docker.com/engine/reference/commandline/update/ (7认同)