泊坞窗在哪个单元上运行“-内存”?选择期望? [英] What unit does the docker run "--memory" option expect?

查看:86
本文介绍了泊坞窗在哪个单元上运行“-内存”?选择期望?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将Docker容器的内存限制为1 GB。根据文档,我们可以使用-memory 选项指定所需的内存限制:

I'd like to constrain the memory of a Docker container to 1 GB. According to the documentation, we can specify the desired memory limit using the --memory option:

$ docker run --memory <size> ...

但是,文档 不描述页面上任意位置的参数格式或单位


-内存,-m         内存限制

--memory , -m           Memory limit

我应该向-内存和其他相关单位提供什么单位-内存保留-内存交换之类的选项?只是字节?

What units should I supply to --memory and other related options like --memory-reservation and --memory-swap? Just bytes?

推荐答案

我是RTFM的经典案例。 -内存选项支持单位后缀,因此我们不需要计算确切的字节数:

Classic case of RTFM on my part. The --memory option supports a unit suffix so we don't need to calculate the exact byte number:


 -m, --memory=""
      Memory limit (format: <number>[<unit>], where unit = b, k, m or g)

   Allows you to constrain the memory available to a container. If the
   host supports swap memory, then the -m memory setting can be larger
   than physical RAM. If a limit of 0 is specified (not using -m), the
   container's memory is not limited. The actual limit may be rounded up
   to a multiple of the operating system's page size (the value would be
   very large, that's millions of trillions).


因此,启动一个内存限制为1 GB的容器问题中所述,这两个命令都将起作用:

So, to start a container with a 1 GB memory limit as described in the question, both of these commands will work:

$ docker run --memory 1g ... 
$ docker run --memory 1073741824 ...

-内存-保留-内存交换选项也支持此约定。

The --memory-reservation and --memory-swap options also support this convention.

这篇关于泊坞窗在哪个单元上运行“-内存”?选择期望?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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