[英]Ran out of Docker disk space
I have this Docker command: 我有这个Docker命令:
docker run -d mongo
this will build and run a mongodb server running in a docker container 这将构建并运行在docker容器中运行的mongodb服务器
However, I get an error: 但是,我收到一个错误:
no space left on device
I am on MacOS, and using the newer versions of Docker which use hyper-v instead of VirtualBox (I think that's correct). 我在MacOS上,并使用较新版本的Docker,它使用hyper-v而不是VirtualBox(我认为这是正确的)。
Here is the exact error message from the mongo
container: 以下是来自
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
Any idea how to fix this and prevent it from happening in future? 知道如何解决这个问题并防止将来发生这种情况吗?
As suggested, the output of df -h
is: 如建议的那样,
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
Output of docker info
is: 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
As you state in the comments to the question, ls -altrh ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2
returns the following: 正如您在问题的评论中所述,
ls -altrh ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2
返回以下内容:
-rw-r--r--@ 1 alexamil staff 53G
This is a known bug on MacOS (actually, not only) and an official dev comment could be found here . 这是MacOS上的一个已知错误(实际上,不仅仅是),可以在这里找到正式的开发者评论。 Except for one thing: I read, that different people get different size limit.
除了一件事:我读到,不同的人有不同的大小限制。 In the comment it is 64Gb, but for another person it was 20Gb.
在评论中它是64Gb,但对于另一个人它是20Gb。
There are a couple walkarounds, but no definite solution that I could find. 有几个走路,但我找不到明确的解决方案。
Run docker ps -a
and manually remove all unused containers. 运行
docker ps -a
并手动删除所有未使用的容器。 Then run docker images
and remove manually all the intermediate and unused images. 然后运行
docker images
并手动删除所有中间和未使用的图像。
Delete the Docker.qcow2
file entirely. 完全删除
Docker.qcow2
文件。 But you will lose all images and containers. 但是你会失去所有的图像和容器。 Completely.
完全。
Another way is to run docker volume prune
, which will remove all unused volumes 另一种方法是运行
docker volume prune
,它将删除所有未使用的卷
Another idea that comes to me is to expand the disk image size with QEMU or something like it: 另一个想法是使用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
After you expanded the image, you will need to run a VM in which you should run GParted against Docker.qcow2 and expand the partition to use added space. 展开图像后,您将需要运行一个VM,在该VM中,您应该针对Docker.qcow2运行GParted并展开分区以使用添加的空间。 You could use GParted Live ISO for that:
您可以使用GParted Live ISO:
$ qemu-system-x86_64 -drive file=Docker.qcow2 -m 512 -cdrom ~/Downloads/gparted-live.iso -boot d -device usb-mouse -usb
Some people report this either doesn't work or doesn't help. 有些人报告这不起作用或没有帮助。
Create a substitute image with desired size (120G): 创建所需大小的替代图像(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
data.qcow2
is copied to ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2
when you restart docker. 重新启动
~/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
。
This walkaround comes from this comment . 本回顾来自此评论 。
Hope this helps. 希望这可以帮助。 Good luck!
祝好运!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.