超出Docker磁盘空间
我有这个Docker命令:
docker run -d mongo
这将构build并运行在docker容器中运行的mongodb服务器
但是,我收到一个错误:
no space left on device
我在MacOS上,并使用更新版本的Docker使用hyper-v而不是VirtualBox(我认为这是正确的)。
这是从mongo
容器确切的错误信息:
$ docker logs efee16702c5756659d563b98d4ae0f58ecf1f1bba8a54f63443c0ae4b520ab4e about to fork child process, waiting until server is ready for connections. forked process: 21 2017-05-04T20:23:51.412+0000 I CONTROL [main] ***** SERVER RESTARTED ***** 2017-05-04T20:23:51.430+0000 I CONTROL [main] ERROR: Cannot write pid file to /tmp/tmp.Lo035QkbfL: No space left on device ERROR: child process failed, exited with error number 1
任何想法如何解决这个问题,并防止在未来发生?
如上所述, df -h
的输出是:
Filesystem Size Used Avail Capacity iused ifree %iused Mounted on /dev/disk1 465Gi 116Gi 349Gi 25% 1963838 4293003441 0% / devfs 183Ki 183Ki 0Bi 100% 634 0 100% /dev map -hosts 0Bi 0Bi 0Bi 100% 0 0 100% /net map auto_home 0Bi 0Bi 0Bi 100% 0 0 100% /home
docker info
输出是:
$ docker info Containers: 5 Running: 0 Paused: 0 Stopped: 5 Images: 741 Server Version: 17.03.1-ce Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Native Overlay Diff: true Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Swarm: inactive Runtimes: runc Default Runtime: runc Init Binary: docker-init containerd version: 4ab9917febca54791c5f071a9d1f404867857fcc runc version: 54296cf40ad8143b62dbcaa1d90e520a2136ddfe init version: N/A (expected: 949e6facb77383876aeff8a6944dde66b3089574) Security Options: seccomp Profile: default Kernel Version: 4.9.13-moby Operating System: Alpine Linux v3.5 OSType: linux Architecture: x86_64 CPUs: 4 Total Memory: 1.952 GiB Name: moby ID: OR4L:WYWW:FFAP:IDX3:B6UK:O2AN:UVTO:EPH6:GYSV:4GV4:L5WP:BQTH Docker Root Dir: /var/lib/docker Debug Mode (client): false Debug Mode (server): true File Descriptors: 17 Goroutines: 30 System Time: 2017-05-04T20:45:27.056157913Z EventsListeners: 1 No Proxy: *.local, 169.254/16 Registry: https://index.docker.io/v1/ Experimental: true Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false
当你在这个问题的注释中声明, ls -altrh ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2
返回如下内容:
-rw-r--r--@ 1 alexamil staff 53G
这是MacOS上的一个已知的错误(实际上,不仅),官方的开发者评论可以在这里find。 除了一件事:我读过,不同的人得到不同的大小限制。 在评论中是64Gb,但另一个人是20Gb。
有几个绕圈,但没有明确的解决办法,我可以find。
手册之一
运行docker ps -a
并手动删除所有未使用的容器。 然后运行docker images
并手动删除所有中间和未使用的图像。
最简单的一个
完全删除Docker.qcow2
文件。 但是你会失去所有的图像和容器。 完全。
不那么简单
另一种方法是运行docker volume prune
,这将删除所有未使用的卷
resize(保持数据)
另一个想法是用QEMU或类似的东西来扩展磁盘映像大小:
$ brew install qemu $ /Applications/Docker.app/Contents/MacOS/qemu-img resize ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2 +5G
展开图像之后,您将需要运行一个虚拟机,您应该在其中运行GParted对Docker.qcow2并展开分区以使用添加的空间。 你可以使用GParted Live ISO:
$ qemu-system-x86_64 -drive file=Docker.qcow2 -m 512 -cdrom ~/Downloads/gparted-live.iso -boot d -device usb-mouse -usb
有人报告说这个不行或者没有帮助。
另一个resize(抹去数据)
创build所需大小(120G)的替代图像:
$ qemu-img create -f qcow2 ~/data.qcow2 120G $ cp ~/data.qcow2 /Application/Docker.app/Contents/Resources/moby/data.qcow2 $ rm ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2
当您重新启动~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2
时, data.qcow2
被复制到~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2
。
这个步骤来自这个评论 。
希望这可以帮助。 祝你好运!