服务器 Docker 空间清理

查看当前磁盘情况
df -h
du -h -x --max-depth=1

查看当前磁盘情况
docker system df
docker system prune命令可以用于清理磁盘,删除关闭的容器、无用的数据卷和网络,以及dangling镜像(即无tag的镜像)。
docker info 查看当前Docker 的部署运行情况

registry开启删除
查看默认配置
docker exec -it registry sh -c 'cat /etc/docker/registry/config.yml'
开启删除(添加 delete: enabled: true)
docker exec -it registry sh -c "sed -i '/storage:/a\ delete:' /etc/docker/registry/config.yml"
docker exec -it registry sh -c "sed -i '/delete:/a\ enabled: true' /etc/docker/registry/config.yml"
重启
docker restart registry
查询、删除镜像
查询镜像
curl <仓库地址>/v2/_catalog

查询镜像tag(版本)
curl <仓库地址>/v2/<镜像名>/tags/list

删除镜像API
curl -I -X DELETE "<仓库地址>/v2/<镜像名>/manifests/<镜像digest_hash>"

获取镜像digest_hash
curl <仓库地址>/v2/<镜像名>/manifests/
--header "Accept: application/vnd.docker.distribution.manifest.v2+json"

[https://www.cnblogs.com/kcxg/p/10760829.html]( registry 相关说明参考)

posted on 2021-12-23 17:28  知识相信未来  阅读(76)  评论(0编辑  收藏  举报

导航