Linux入门教程:Docker命令行参考(27) – docker update更新容器配置,docker基本命令可以使用这个命令限制


Usage:  docker update [OPTIONS] CONTAINER [CONTAINER...]   Update configuration of one or more containers   Options:       --blkio-weight value          Block IO (relative weight), between 10 and 1000       --cpu-period int              Limit CPU CFS (Completely Fair Scheduler) period       --cpu-quota int               Limit CPU CFS (Completely Fair Scheduler) quota   -c, --cpu-shares int              CPU shares (relative weight)       --cpuset-cpus string          CPUs in which to allow execution (0-3, 0,1)       --cpuset-mems string          MEMs in which to allow execution (0-3, 0,1)       --help                        Print usage       --kernel-memory string        Kernel memory limit   -m, --memory string               Memory limit       --memory-reservation string   Memory soft limit       --memory-swap string          Swap limit equal to memory plus swap: '-1' to enable unlimited swap       --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

$ docker update --cpu-shares 512 abebf7571666

更新容器的cpu-shares和memory

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

更新容器restart策略

$ docker update --restart=on-failure:3 abebf7571666 hopeful_morse

相关内容