[Docker基础]如何清除不用的资源

Docker - How to cleanup resources

有时你可能需要清理Docker中不用的资源,特别是在学习Docker过程中创建的镜像、容器、网络、存储卷等。

delete volumes

  • 删除挂载的存储卷
$ docker volume rm $(docker volume ls -qf )

delete networks

  • 删除创建的网络
$ docker network ls
$ docker network ls | grep "bridge"
$ docker network rm $(docker network ls | grep "bridge" | awk '//{print $1}')
$ docker network ls | awk '$3 == "bridge" && $2 != "bridge" { print $1 }'

delete images

  • 删除镜像(删除镜像前需要停止所运行的容器并删除容器)
$ docker images
$ docker rmi $(docker images --filter "dangling=true" -q --no-trunc)
$ docker rmi $(docker images | grep "none" | awk '//{print $3}')

delete containers

  • 删除容器
$ docker ps
$ docker ps -a
$ docker rm $(docker ps -qa --no-trunc --filter "status=exited")

resize disk space for docker vm

$ docker-machine create --driver virtualbox --virtualbox-disk-size "40000" default
posted @ 2017-12-07 14:25  SStriver  阅读(1536)  评论(0编辑  收藏  举报