"virtual memory exhausted" 构建 Docker 图像时
"virtual memory exhausted" when building Docker image
构建 Docker 图像时,有一些 C++ 脚本的编译,我最终遇到如下错误:
src/amun/CMakeFiles/cpumode.dir/build.make:134: recipe for target 'src/amun/CMakeFiles/cpumode.dir/cpu/decoder/encoder_decoder_state.cpp.o' failed
virtual memory exhausted: Cannot allocate memory
但是在主机上构建相同的 .cpp
代码时,它工作正常。
经过一些检查,错误消息似乎与人们在 Raspberry Pi、https://www.bitpi.co/2015/02/11/how-to-change-raspberry-pis-swapfile-size-on-rasbian/
上看到的错误消息相似
经过更多谷歌搜索,Mac forum 上的 post 表示:
Swapfiles are dynamically created as needed, until either the disk is
full, or the kernel runs out of page table space. I do not think you
can change the page table space limits in the Mac OS X kernel. I have
not seen anything in all the years I've been using OS X.
有没有办法在 Mac OS 的基础上为 Docker 增加交换 space?
如果没有,在构建 Docker 图像时还可以如何克服 "virtual memory exhausted" 错误?
这对于 XHyve 来说似乎并不简单。
如前所述 in this thread
I think the default size of the VM is 16GB. I kept running out of swap space even after bumping the ram on the VM up to 16GB.
检查用于 VirtualBox VM 的方法是否适用于 XHyve:参见“”
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
还要检查此 Digital Ocean Setup,再次在您的 XHyve 上下文中进行测试。
mkswap
is also seen here or in docker-root-xhyve/contrib/makehdd/makehdd.sh
.
由于您的主机有足够的可用内存,我建议您为后面的 Docker 虚拟机分配更多内存。
如前所述:
As I can see that you are on OSX, which runs docker over a Linux VM. Configure the max memory clicking the whale icon in the task bar. By default is 2G.
更多信息:https://docs.docker.com/docker-for-mac/#memory
构建 Docker 图像时,有一些 C++ 脚本的编译,我最终遇到如下错误:
src/amun/CMakeFiles/cpumode.dir/build.make:134: recipe for target 'src/amun/CMakeFiles/cpumode.dir/cpu/decoder/encoder_decoder_state.cpp.o' failed
virtual memory exhausted: Cannot allocate memory
但是在主机上构建相同的 .cpp
代码时,它工作正常。
经过一些检查,错误消息似乎与人们在 Raspberry Pi、https://www.bitpi.co/2015/02/11/how-to-change-raspberry-pis-swapfile-size-on-rasbian/
上看到的错误消息相似经过更多谷歌搜索,Mac forum 上的 post 表示:
Swapfiles are dynamically created as needed, until either the disk is full, or the kernel runs out of page table space. I do not think you can change the page table space limits in the Mac OS X kernel. I have not seen anything in all the years I've been using OS X.
有没有办法在 Mac OS 的基础上为 Docker 增加交换 space?
如果没有,在构建 Docker 图像时还可以如何克服 "virtual memory exhausted" 错误?
这对于 XHyve 来说似乎并不简单。
如前所述 in this thread
I think the default size of the VM is 16GB. I kept running out of swap space even after bumping the ram on the VM up to 16GB.
检查用于 VirtualBox VM 的方法是否适用于 XHyve:参见“
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
还要检查此 Digital Ocean Setup,再次在您的 XHyve 上下文中进行测试。
mkswap
is also seen here or in docker-root-xhyve/contrib/makehdd/makehdd.sh
.
由于您的主机有足够的可用内存,我建议您为后面的 Docker 虚拟机分配更多内存。
如前所述
As I can see that you are on OSX, which runs docker over a Linux VM. Configure the max memory clicking the whale icon in the task bar. By default is 2G.
更多信息:https://docs.docker.com/docker-for-mac/#memory