使docker build--内存交换=20g使用可用交换空间?
我已经运行了使docker build--内存交换=20g使用可用交换空间?,docker,swap,windows-subsystem-for-linux,Docker,Swap,Windows Subsystem For Linux,我已经运行了free-h,看到我有29G的交换空间 total used free shared buff/cache available Mem: 15G 6.9G 8.8G 17M 223M 8.9G Swap: 29G 2.0M 29G 我还启用了100个交换 $ sudo
free-h
,看到我有29G的交换空间
total used free shared buff/cache available
Mem: 15G 6.9G 8.8G 17M 223M 8.9G
Swap: 29G 2.0M 29G
我还启用了100个交换
$ sudo sysctl vm.swappiness=100
vm.swappiness = 100
$ cat /proc/sys/vm/swappiness
100
但是,docker build--memory swap=20g
似乎没有使用交换空间。这是整个docker构建过程中htop
的输出
1 [|||||||||||||||| 18.7%]
2 [||||||| 7.3%]
3 [|||||||||||||||||||||| 26.5%]
4 [||||||||||||||| 18.0%]
Mem[||||||||||||||||||||||||||||||||||| 6.47G/15.9G]
Swp[| 2.00M/29.6G]
这是docker build命令:
docker build --build-arg NODE_OPTIONS="--max-old-space-size=325" \
--memory=600m --memory-swap=20g \
--cpu-period=100000 --cpu-quota=50000 \
--no-cache --tag farm_app_image:latest --file Dockerfile .
docker构建似乎正在耗尽RAM,因为构建的内部进程(NodeJS)耗尽堆空间并崩溃。此外,在崩溃之前,内存会立即达到最大值:
shaun@DESKTOP-5T629JB:/mnt/c/Users/bigfo$ docker ps -q | xargs docker stats --no-stream
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
66bdf8efb492 charming_maxwell 51.72% 562.2MiB / 600MiB 93.70% 46.8MB / 1.53MB 277MB / 230MB 94
为什么它没有使用交换空间就耗尽了RAM?如何使其使用可用的交换空间?可能是您应该尝试使用
--privileged
标志运行它
docker run -ti --privileged yourimage
但是要确保你知道你在做什么
你也应该阅读