内容简介:不久之前看了一下香港的服务器,小小的15G空间已经没有剩余了,纳闷什么东西那么占用空间用用
不久之前看了一下香港的服务器,小小的15G空间已经没有剩余了,纳闷什么东西那么占用空间
用 du -sh *
看了一下,发现 docker 的overlay2文件夹竟然占据了5.8G的空间,之前是为了测试一下一些工具,忘了删,没想一两个 工具 竟然能占用那么大的空间。
用 docker system df
可以查看docker的镜像,容器和本地卷等空间占用情况。
TYPE TOTAL ACTIVE SIZE RECLAIMABLE Images 2 0 5.786GB 5.786GB (100%) Containers 0 0 0B 0B Local Volumes 0 0 0B 0B Build Cache 0 0 0B 0B
docker system prune
命令可以用于清理磁盘,删除关闭的容器、无用的数据卷和网络,以及 dangling 镜像(即无 tag 的镜像)。
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测试那些工具了,所以打算把镜像全部删除。
那么用 docker system prune -a
命令可以清理得更加彻底,将没有容器使用 Docker 镜像都删掉。注意,这两个命令会把你暂时关闭的容器,以及暂时没有用到的 Docker 镜像都删掉。
WARNING! This will remove:
- all stopped containers
- all networks not used by at least one container
- all images without at least one container associated to them
- all build cache
Are you sure you want to continue? [y/N] y
其他命令
对于悬空镜像和未使用镜像可以使用手动进行个别删除:
- 删除所有悬空镜像,不删除未使用镜像:
docker rmi $(docker images -f "dangling=true" -q)
- 删除所有未使用镜像和悬空镜像
docker rmi $(docker images -q)
-
清理卷
如果卷占用空间过高,可以清除一些不使用的卷,包括一些未被任何容器调用的卷(-v 详细信息中若显示 LINKS = 0,则是未被调用):
删除所有未被容器引用的卷:
docker volume rm $(docker volume ls -qf dangling=true)
-
容器清理
如果发现是容器占用过高的空间,可以手动删除一些:
删除所有已退出的容器:
docker rm -v $(docker ps -aq -f status=exited)
删除所有状态为dead的容器
docker rm -v $(docker ps -aq -f status=dead)
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
An Introduction to Probability Theory and Its Applications
William Feller / Wiley / 1991-1-1 / USD 120.00
Major changes in this edition include the substitution of probabilistic arguments for combinatorial artifices, and the addition of new sections on branching processes, Markov chains, and the De Moivre......一起来看看 《An Introduction to Probability Theory and Its Applications》 这本书的介绍吧!