【发布时间】:2019-11-16 20:52:09
【问题描述】:
我已经运行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 个swappiness。
$ 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 build 似乎内存不足,因为 build 的内部进程 (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
为什么在不使用交换空间的情况下内存不足?我们怎样才能让它使用可用的交换空间?
【问题讨论】:
标签: docker swap windows-subsystem-for-linux