docker内存不足

时间:2016-12-16 15:11:53

标签: docker out-of-memory

我是docker的新用户,现有的脚本在一台机器上运行但在另一台机器上运行却没有问题。我愿意阅读文档和现有答案,但在本主题的许多抽象层次上都有点遗失。

在docker中运行应用程序会导致内存不足异常。我用--ulimit memlock -1:-1启动了docker,似乎没有应用其他内存限制。

df -h在docker yield

root@localhost:/# df -h
Filesystem                                                                                         Size  Used Avail Use% Mounted on
/dev/mapper/docker-253:0-1312128-9219e5dbff0bc6da3a663fab31ec34e6f6b28ba6c8fbd3b343d9131d41f6b1c9   10G  3.0G  7.1G  30% /
tmpfs                                                                                              3.9G     0  3.9G   0% /dev
tmpfs                                                                                              3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/mapper/fedora-root                                                                             50G   20G   28G  42% /etc/hosts
/dev/mapper/fedora-home                                                                            401G  151G  231G  40% /var/results
shm                                                                                                 64M     0   64M   0% /dev/shm

当OOM发生时,第一个文件系统用于95%。 10G的限制来自哪里?我在哪里可以调整它?

我的设备的所有分区肯定都有足够的可用空间。

[uscholz@localhost RegressionTesting]$ docker info
Containers: 2
 Running: 1
 Paused: 0
 Stopped: 1
Images: 52
Server Version: 1.10.3
Storage Driver: devicemapper
 Pool Name: docker-253:0-1312128-pool
 Pool Blocksize: 65.54 kB
 Base Device Size: 10.74 GB
 Backing Filesystem: xfs
 Data file: /dev/loop0
 Metadata file: /dev/loop1
 Data Space Used: 12.17 GB
 Data Space Total: 107.4 GB
 Data Space Available: 32.16 GB
 Metadata Space Used: 7.889 MB
 Metadata Space Total: 2.147 GB
 Metadata Space Available: 2.14 GB
 Udev Sync Supported: true
 Deferred Removal Enabled: false
 Deferred Deletion Enabled: false
 Deferred Deleted Device Count: 0
 Data loop file: /var/lib/docker/devicemapper/devicemapper/data
 WARNING: Usage of loopback devices is strongly discouraged for production use. Either use `--storage-opt dm.thinpooldev` or use `--storage-opt dm.no_warn_on_loop_devices=true` to suppress this warning.
 Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
 Library Version: 1.02.122 (2016-04-09)
Execution Driver: native-0.2
Logging Driver: journald
Plugins: 
 Volume: local
 Network: bridge null host
Kernel Version: 4.8.12-200.fc24.x86_64
Operating System: Fedora 24 (Twenty Four)
OSType: linux
Architecture: x86_64
Number of Docker Hooks: 2
CPUs: 8
Total Memory: 7.787 GiB
Name: localhost.localdomain
ID: YXHN:34PG:ZQA3:P4DU:4TFY:6THC:VFI2:E7BE:IGOW:2TTH:3BS7:3OOD
Registries: docker.io (secure)

1 个答案:

答案 0 :(得分:0)

  

10G的限制来自哪里?

它来自dockerd(守护进程),默认为新容器创建特殊的“设备”10G大小

  

我可以在哪里调整它?

您可以通过向dockerd提供--storage-opt dm.basesize=50G设置设备映射存储驱动程序

P.S。:实际上,OOM不是磁盘空间的原因,而是内存,我认为
有两个可能的原因:

  • 你没有真正的记忆。比在docker主机上使用free -m来观看它。容器使用与docker

  • 的主机相同的内存
  • 你没有共享内存。不确定OOM,但是docker默认将/ dev / shm设置为64M。它不适合某些应用程序