Docker命令行参考(27) – docker update更新容器配置

  1. Usage:  docker update [OPTIONS] CONTAINER [CONTAINER...]
  2.  
  3. Update configuration of one or more containers
  4.  
  5. Options:
  6.       --blkio-weight value          Block IO (relative weight), between 10 and 1000
  7.       --cpu-period int              Limit CPU CFS (Completely Fair Scheduler) period
  8.       --cpu-quota int               Limit CPU CFS (Completely Fair Scheduler) quota
  9.   -c, --cpu-shares int              CPU shares (relative weight)
  10.       --cpuset-cpus string          CPUs in which to allow execution (0-3, 0,1)
  11.       --cpuset-mems string          MEMs in which to allow execution (0-3, 0,1)
  12.       --help                        Print usage
  13.       --kernel-memory string        Kernel memory limit
  14.   -m, --memory string               Memory limit
  15.       --memory-reservation string   Memory soft limit
  16.       --memory-swap string          Swap limit equal to memory plus swap: '-1' to enable unlimited swap
  17.       --restart string              Restart policy to apply when a container exits

docker update命令可以动态地更新容器配置。可以使用这个命令限制容器在docker主机上使用太多的资源。可以在命令后台加一个或多个容器来批量更新配置。多个容器名称或ID之间使用空格分隔。
除了–kernel-memory选项,其它的选项可以应用在运行或停止的容器。–kernel-memory只可以应用在已停止的容器。当在已停止的容器运行docker update命令时,更新的配置将在下一次重启容器时生效。
另一个可以更新的命令是restart策略,当执行docker update之后,新的restart策略将立即生效。

示例

更新一个容器为cpu-shares=512

  1. $ docker update --cpu-shares 512 abebf7571666

更新容器的cpu-shares和memory

  1. $ docker update --cpu-shares 512 -m 300M abebf7571666 hopeful_morse

更新容器restart策略

  1. $ docker update --restart=on-failure:3 abebf7571666 hopeful_morse
标签:容器Docker 发布于:2019-11-19 09:21:30