私信  •  关注

Peter Mortensen Innocent Anigb

Peter Mortensen Innocent Anigb 最近创建的主题
Peter Mortensen Innocent Anigb 最近回复了
5 年前
回复了 Peter Mortensen Innocent Anigb 创建的主题 » 本地Docker注册表卷被本地映像100%使用,如何从中释放空间?

#!/bin/bash -x
## Removing stopped container
docker ps -a | grep Exited | awk '{print $1}' | xargs docker rm

## If you do not want to remove all container you can have filter for days and weeks old like below
#docker ps -a | grep Exited | grep "days ago" | awk '{print $1}' | xargs docker rm
#docker ps -a | grep Exited | grep "weeks ago" | awk '{print $1}' | xargs docker rm

## Removing Dangling images
## There are the layers images which are being created during building a Docker image. This is a great way to recover the spaces used by old and unused layers.

docker rmi $(docker images -f "dangling=true" -q)

## Removing images of perticular pattern For example
## Here I am removing images which has a SNAPSHOT with it.

docker rmi $(docker images | grep SNAPSHOT | awk '{print $3}')

## Removing weeks old images

docker images | grep "weeks ago" | awk '{print $3}' | xargs docker rmi

## Similarly you can remove days, months old images too.

原稿

https://github.com/vishalvsh1/docker-image-cleanup

/变量/库/docker

此路径是系统的本地路径,通常位于根分区, .

您可以装载更大的磁盘空间并移动 /var/lib/docker

这样,即使Docker映像占用空间,也不会影响您的系统,因为它将使用其他一些装载位置。

Manage Docker images on local disk