前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Docker container 动态修改内存限制

Docker container 动态修改内存限制

作者头像
机械视角
发布2019-10-23 11:18:33
4.6K0
发布2019-10-23 11:18:33
举报
文章被收录于专栏:TensorbytesTensorbytes

docker动态修改配置用docker update,用法:

代码语言:javascript
复制
docker update -h
Flag shorthand -h has been deprecated, please use --help

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

Update configuration of one or more containers

Options:
      --blkio-weight uint16         Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0)
      --cpu-period int              Limit CPU CFS (Completely Fair Scheduler) period
      --cpu-quota int               Limit CPU CFS (Completely Fair Scheduler) quota
      --cpu-rt-period int           Limit the CPU real-time period in microseconds
      --cpu-rt-runtime int          Limit the CPU real-time runtime in microseconds
  -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

当前要做的是把一个运行着gitlab 的容器内存限制在2048M以内,尝试用: docker update -m 2048m gitlab

报错:

代码语言:javascript
复制
Memory limit should be smaller than already set memoryswap limit, update the memoryswap at the same time

发现问题,docker 默认没有启用memory-swap交换内存,直接设置了内存问题会出问题,也就是说宿主 swap 支持使用多少则容器即可使用多少,如果 –memory-swap 设置小于 –memory则设置不生效。

将memory-swap 设置值为 -1,表示容器程序使用内存受限,而 swap 空间使用不受限制。

代码语言:javascript
复制
docker update --memory 2048m --memory-swap -1 gitlab

问题解决。

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018-09-28,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
容器镜像服务
容器镜像服务(Tencent Container Registry,TCR)为您提供安全独享、高性能的容器镜像托管分发服务。您可同时在全球多个地域创建独享实例,以实现容器镜像的就近拉取,降低拉取时间,节约带宽成本。TCR 提供细颗粒度的权限管理及访问控制,保障您的数据安全。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档