如何使用docker设置分配给容器的资源? [英] How do I set resources allocated to a container using docker?

查看:691
本文介绍了如何使用docker设置分配给容器的资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于这个问题的标题表明我想使用docker(docker.io)为容器设置最大磁盘/内存和CPU使用率。

As the title of this question suggests I'm wanting to set max disk/memory and cpu usage for a container using docker (docker.io).

是有一种方法可以使用docker吗?

Is there a way to do this using just docker?

推荐答案

内存/ CPU

Docker现在支持更多的资源分配选项:

Docker now supports more resource allocation options:


  • CPU共享,通过-c标志

  • 内存限制,通过-m标志

  • 具体的CPU核心,通过--cpuset标志

有关详细信息,请查看 docker run --help

Have a look at docker run --help for more details.

如果您可以使用lxc后端( docker -d --exec-driver = lxc ),可以指定更细粒度的资源分配方案,例如:

If you use lxc backend (docker -d --exec-driver=lxc), more fine grained resource allocation schemes can be specified, e.g.:

docker run --lxc-conf="lxc.cgroup.cpuset.cpus = 0,1"\
           --lxc-conf="lxc.cgroup.cpu.shares = 1234"

存储

限制存储有点棘手在这一刻。请参阅以下链接了解更多详情:

Limiting storage is a bit trickier at the moment. Please refer to the following links for more details:

  • Resizing Docker containers with the Device Mapper plugin
  • Question on Resource Limits?
  • devicemapper - a storage backend based on Device Mapper

这篇关于如何使用docker设置分配给容器的资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆