Docker可以控制容器能使用的Memory、CPU、GPU等资源。
docker run命令限制内存的选项如-m或--memory=表示容器可使用的最大内存最小值为4m(4 megabyte);其它可以查阅Docker官方文档Runtime options with Memory, CPUs, and GPUs。
系统开启cgroup相关选项
否则可能会报错“WARNING: Your kernel does not support swap limit capabilities, memory limited without swap.”。
1 |
# cat /etc/default/grub | grep GRUB_CMDLINE_LINUX |