我在Debian 7机器上安装docker的方法如下

$ echo deb http://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list
$ sudo apt-get update
$ curl -sSL https://get.docker.com/ubuntu/ | sudo sh

之后,当我第一次尝试创建一个图像时,它失败了,出现以下错误

 time="2015-06-02T14:26:37-04:00" level=info msg="[8] System error: write /sys/fs/cgroup/docker/01f5670fbee1f6687f58f3a943b1e1bdaec2630197fa4da1b19cc3db7e3d3883/cgroup.procs: no space left on device"

这是docker信息

Containers: 2
Images: 21
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 25
Dirperm1 Supported: true
Execution Driver: native-0.2
Kernel Version: 3.16.0-0.bpo.4-amd64
Operating System: Debian GNU/Linux 7 (wheezy)
CPUs: 2
 Total Memory: 15.7 GiB


WARNING: No memory limit support
 WARNING: No swap limit support

如何增加内存?系统配置存储在哪里?

以下是卡尔的建议:

当我摆脱了所有的图像和容器,它确实释放了一些空间和图像构建运行更长的时间之前失败与相同的错误。问题是,这指的是哪个空间我怎么配置它?


当前回答

我在RHEL机器上也遇到了这个问题。在堆栈溢出和docker-hub社区中,我没有找到任何合适的解决方案。 如果您在执行以下命令后仍面临此问题:

Docker系统全部修剪

最终奏效的解决方案:

docker info To check current docker storage driver Mine was : Storage Driver: devicemapper; If you have storage driver as overlay2 nothing to worry about. Solution will still work for you. df -h This is to check the available file systems on machine and the path where they are mounted. Two mounted path to have a note: /dev/mapper/rootvg-var 7.6G 1.2G 6.1G 16% /var /dev/mapper/rootvg-apps 60G 9.2G 48G 17% /apps Note- By default docker storage path is /var/lib/docker. It has available space ~6 GB and hence all the space related issues. So basically, I have to move default storage to some other storage where available space is more. For me its File sysyem path '/dev/mapper/rootvg-apps' which is mounted on /apps. Now task is to move /var/lib/docker to something like /apps/newdocker/docker. mkdir /apps/newdocker/docker chmod -R 777 /apps/newdocker/docker Update docker.serive file on linux which resides under: /usr/lib/systemd/system vi /usr/lib/systemd/system/docker.service if storage device is devicemapper , comment existing ExecStart line and add below under [Service]: ExecStart= ExecStart=/usr/bin/dockerd -s devicemapper --storage-opt dm.fs=xfs --storage-opt dm.basesize=40GB -g /apps/newdocker/docker --exec-opt native.cgroupdriver=cgroupfs Or if storage device is overlay2: just add -g /apps/newdocker/docker in the existing ExexStart statement. Something like ExecStart=/usr/bin/dockerd -g /apps/newdocker/docker -H fd:// --containerd=/run/containerd/containerd.sock rm -rf /var/lib/docker (It will delete all existing docker data) systemctl stop docker ps aux | grep -i docker | grep -v grep If no output has been produced by the above command, reload systemd daemon by below command. systemctl daemon-reload systemctl start docker docker info Check out the Data Space Available: 62.15GB after mouting to docker to new File system. DONE

其他回答

我在RHEL机器上也遇到了这个问题。在堆栈溢出和docker-hub社区中,我没有找到任何合适的解决方案。 如果您在执行以下命令后仍面临此问题:

Docker系统全部修剪

最终奏效的解决方案:

docker info To check current docker storage driver Mine was : Storage Driver: devicemapper; If you have storage driver as overlay2 nothing to worry about. Solution will still work for you. df -h This is to check the available file systems on machine and the path where they are mounted. Two mounted path to have a note: /dev/mapper/rootvg-var 7.6G 1.2G 6.1G 16% /var /dev/mapper/rootvg-apps 60G 9.2G 48G 17% /apps Note- By default docker storage path is /var/lib/docker. It has available space ~6 GB and hence all the space related issues. So basically, I have to move default storage to some other storage where available space is more. For me its File sysyem path '/dev/mapper/rootvg-apps' which is mounted on /apps. Now task is to move /var/lib/docker to something like /apps/newdocker/docker. mkdir /apps/newdocker/docker chmod -R 777 /apps/newdocker/docker Update docker.serive file on linux which resides under: /usr/lib/systemd/system vi /usr/lib/systemd/system/docker.service if storage device is devicemapper , comment existing ExecStart line and add below under [Service]: ExecStart= ExecStart=/usr/bin/dockerd -s devicemapper --storage-opt dm.fs=xfs --storage-opt dm.basesize=40GB -g /apps/newdocker/docker --exec-opt native.cgroupdriver=cgroupfs Or if storage device is overlay2: just add -g /apps/newdocker/docker in the existing ExexStart statement. Something like ExecStart=/usr/bin/dockerd -g /apps/newdocker/docker -H fd:// --containerd=/run/containerd/containerd.sock rm -rf /var/lib/docker (It will delete all existing docker data) systemctl stop docker ps aux | grep -i docker | grep -v grep If no output has been produced by the above command, reload systemd daemon by below command. systemctl daemon-reload systemctl start docker docker info Check out the Data Space Available: 62.15GB after mouting to docker to new File system. DONE

不要只运行docker prune命令。它将删除所有的docker网络、容器和映像。所以你可能最终也会丢失重要的数据。

错误显示“设备上没有剩余空间”,所以我们只需要释放一些空间。

腾出空间最简单的方法就是删除悬空的图像。

当旧创建的图像不被使用时,这些图像被称为悬空图像或有一些缓存图像,以及你可以删除。

使用下面的命令。 列出所有悬挂图像。

docker images -f "dangling=true" -q

按映像id删除映像。

docker rmi IMAGE_ID

这样你就可以腾出一些空间,重新开始使用docker了:)

目前的最佳实践是:

docker system prune

在接受结果之前,请注意该命令的输出:

WARNING! This will remove:
  - all stopped containers
  - all networks not used by at least one container
  - all dangling images
  - all dangling build cache

Are you sure you want to continue? [y/N]

换句话说,继续执行这个命令是永久的。请记住,最佳实践是将停止的容器视为短暂的,即您应该使用Docker设计您的工作,不要保留这些停止的容器。如果你不主动调试容器,你可以考虑在运行时使用——rm标志。

请务必阅读这个答案,回复:卷

如果docker系统修剪不适合你,你可能也会对这个答案感兴趣。

那么多关于修剪声明的帖子。因为这个命令确实会清理docker文件,如果实际存储空间被占用,它不会修复您的系统。对我来说,问题是服务器的存储空间太满了。因此,我有两个选择。

选项1:清理现有空间

运行别人说过的所有系统修剪命令。 df -H,剩下多少空间? 用du——block-size=M -a / | sort -n -r | head -n 20检查是什么占用了系统这么多的空间,这将显示20个最大的文件。 删除文件或将其移出系统。

选择2:获得更多空间

为硬盘驱动器增加更多空间,然后扩展。如果你像我一样只有一个HD,我必须挂载名为“gparted”的操作系统并扩展驱动器。

在我的案例中,安装ubuntu服务器18.04.1(出于某种奇怪的原因)创建了一个LVM逻辑卷,大小只有4gb,而不是750gb。 因此,当拉图像时,我会得到这个“设备上没有空间”错误。 解决方法很简单:

lvextend -l 100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv