主页
- 个人微信公众号:密码应用技术实战
- 个人博客园首页:https://www.cnblogs.com/informatics/
问题描述
在Mac上进行docker构建时,偶尔会遇到以下问题
Failed to copy files: userspace copy failed:
write /var/lib/docker/volumes/xxx/_data/xxx.dbf:
no space left on device
这种问题一般是由于频繁进行docker构建和运行,每次构建都会保留一些临时文件,占用了大量的存储空间。如果镜像、容器和本地Volume等docker相关的持久化存储消耗空间较大,再进行docker的构建和运行就会碰到以上问题。
解决方案
- 使用
docker system df
命令查看docker持久化存储占用情况
➜ ~ docker system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 49 13 34.04GB 31.1GB (91%)
Containers 14 1 5.761GB 5.752GB (99%)
Local Volumes 0 0 0B 0B
Build Cache 177 0 11.39GB 11.39GB
发现Containers
占用了大量空间
- 清理Containers
# 清理containers
➜ ~ docker rm `docker ps -aq`
# 重新查看docker持久化存储占用空间
➜ ~ docker system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 49 1 34.04GB 34.04GB (100%)
Containers 1 1 8.367MB 0B (0%)
Local Volumes 0 0 0B 0B
Build Cache 177 0 11.39GB 11.39GB
从上面命令输出可以看出,Containers占用的存储已被大部分回收。
docker命令
- 清理无名docker images
# 查询无名docker镜像
➜ ~ docker images | grep none
<none> <none> 71ee97a16e71 47 minutes ago 823MB
<none> <none> 2016ba05a0bd 58 minutes ago 1.04GB
<none> <none> f9e7ceb56af9 About an hour ago 1.04GB
<none> <none> 6da657f62f88 About an hour ago 1.04GB
# 清理无名docker镜像
➜ ~ docker images | grep 'none' | awk '{print $3}' | xargs docker rmi
Deleted: sha256:71ee97a16e718bfed27e77aa20ce7a84613bc9db654880ae0572c3790f72e818
Deleted: sha256:84332b4724450b9387e8170a8e97f32a91c0a901ce7f79a811c244085559dc0a
Deleted: sha256:11de3bb1714a313d0f0c4c6815743c0b708e68da9bfbb3c6cbf4590f15b6bc59
Deleted: sha256:54f0f4c036757c04ce32abe8a0f008e67e39706214ce7fd346a80b7dbc6b4953
Deleted: sha256:19d81f07d04b03f24569a3d6297bccfbb91cf96cc750aac32ef7fa0e4acee131
Deleted: sha256:e8c8a6bde26ebde25f5b4302b57191aea15f71dcf345a8f1e6918b95a18db1ef
Deleted: sha256:2016ba05a0bd8e8d8ccb33dd437e4f50e3092751df1dc12633bbe0eb507c6bad
Deleted: sha256:b99f41317039f1d957ccea10817f76264bf8605c5167c033e5b4b2b725211698
Deleted: sha256:c1aea5e7327bed7c2358dc423e04dc952f495af067b3605937958fe92dd159af
Deleted: sha256:06304242456d6a4a6e4a860aee2e9c744a1c875c5fd6b2153780661ff34b26de
Deleted: sha256:f9e7ceb56af954bf393ec2ca414a4210f8fc99dc0174a5ef1cfcac718ee0698d
- 清理docker volumes
docker volume ls | awk '{print $2}' | xargs -I {} docker volume rm {}
标签:files,no,Deleted,space,0B,GB,docker,sha256,Containers
From: https://www.cnblogs.com/informatics/p/18008300