如何增加boot2docker虚拟机中可用的交换空间? [英] How to increase the swap space available in the boot2docker virtual machine?

查看:121
本文介绍了如何增加boot2docker虚拟机中可用的交换空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在没有太多RAM的机器上运行需要大量内存的docker容器.我一直试图增加可用于该容器的交换空间,但无济于事.这是我尝试的最后一个命令:

I would like to run a docker container that requires a lot of memory on a machine that doesn't have much RAM. I have been trying to increase the swap space available for the container to no avail. Here is the last command I tried:

docker run -d -m 1000M --memory-swap=10000M --name=my_container my_image

按照以下有关如何检查内存指标的提示,我发现以下:

Following these tips on how to check memory metrics I found the following:

$ boot2docker ssh

docker@boot2docker:~$ cat /sys/fs/cgroup/memory/docker/35af5a072751c7af80ce7a255a01ab3c14b3ee0e3f15341f7bb22a777091c67b/memory.stat
cache 454656
rss 65015808
rss_huge 29360128
mapped_file 208896
writeback 0
swap 0
pgpgin 31532
pgpgout 22702
pgfault 49372
pgmajfault 0
inactive_anon 28672
active_anon 65183744
inactive_file 241664
active_file 16384
unevictable 0
hierarchical_memory_limit 1048576000
hierarchical_memsw_limit 10485760000
total_cache 454656
total_rss 65015808
total_rss_huge 29360128
total_mapped_file 208896
total_writeback 0
total_swap 0
total_pgpgin 31532
total_pgpgout 22702
total_pgfault 49372
total_pgmajfault 0
total_inactive_anon 28672
total_active_anon 65183744
total_inactive_file 241664
total_active_file 16384
total_unevictable 0

是否可以在仅具有4G物理内存的机器上运行需要5G内存的容器?

Is it possible to run a container that requires 5G of memory on a machine that only has 4G of physical memory?

推荐答案

GitHub问题在以下方面非常有帮助弄清楚如何增加boot2docker-vm中可用的交换空间.适应我的情况,我使用以下命令将ssh SSH进入boot2docker-vm并设置了一个新的swapfile:

This GitHub issue was very helpful in figuring out how to increase the swap space available in the boot2docker-vm. Adapting it to my situation I used the following commands to ssh into the boot2docker-vm and set up a new swapfile:

boot2docker ssh
export SWAPFILE=/mnt/sda1/swapfile
sudo dd if=/dev/zero of=$SWAPFILE bs=1024 count=4194304
sudo mkswap $SWAPFILE
sudo chmod 600 $SWAPFILE
sudo swapon $SWAPFILE
exit

这篇关于如何增加boot2docker虚拟机中可用的交换空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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