我在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
如何增加内存?系统配置存储在哪里?
以下是卡尔的建议:
当我摆脱了所有的图像和容器,它确实释放了一些空间和图像构建运行更长的时间之前失败与相同的错误。问题是,这指的是哪个空间我怎么配置它?
我也犯了同样的错误,用这种方法来解决:
1。删除Docker中的孤立卷,可以使用内置的Docker volume命令。内置命令还会删除/var/lib/docker/volumes中不是卷的任何目录,因此请确保您没有在其中放入想要保存的任何内容。
警告:如果你想保留一些数据,要非常小心
清理:
$ docker volume rm $(docker volume ls -qf dangling=true)
额外的命令:
列出悬挂卷:
$ docker volume ls -qf dangling=true
列出所有卷:
$ docker volume ls
2。还要考虑删除所有未使用的图像。
首先删除<none>映像(这些映像有时是在构建映像时生成的,如果由于某种原因,映像构建被中断,它们将留在那里)。
这是我用来删除它们的一个很好的脚本
docker rmi $(docker images | awk '/^<none>/ {print $3}')
然后,如果你使用Docker Compose为每个项目在本地构建图像。你最终会得到很多图片,通常和你的文件夹一样命名(例如,如果你的项目文件夹名为Hello,你会发现图片名为Hello_blablabla)。所以也要考虑删除所有这些图片
您可以编辑上面的脚本以删除它们或手动使用
Docker rmi {image-name}
我在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
这可能是因为默认存储空间设置为40GB(默认路径,/var/lib/docker)
您可以更改存储卷指向不同的路径
编辑文件-> /etc/sysconfig/docker-storage
在行下更新(如果不存在则添加)
DOCKER_STORAGE_OPTIONS = '——存储驱动=叠加图= CUSTOM_PATH '
重启码头工人
Systemctl stop docker
systemctl daemon-reload
Systemctl start docker
如果你运行命令docker info(它应该显示存储驱动为overlay)