Last active
August 20, 2019 12:06
-
-
Save maxwu/1364bce6fcaa711fb5a0a81b3cfc8e30 to your computer and use it in GitHub Desktop.
Remove obsoleted docker images
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #删除虚悬镜像 | |
| docker image prune --force | |
| #删除停止或一直处于已创建状态的实例 | |
| docker ps --filter "status=exited"|sed -n -e '2,$p'|awk '{print $1}'|xargs docker rm | |
| docker ps --filter "status=created"|sed -n -e '2,$p'|awk '{print $1}'|xargs docker rm | |
| #删除REPOSITORY是长uuid的镜像 | |
| docker images | sed -n -e '2,$p'|awk '{if($1 ~ /[0-9a-f]{32}/) print $1":"$2}'|xargs docker rmi | |
| #删除TAG是长uuid的镜像 | |
| docker images | sed -n -e '2,$p'|awk '{if($2 ~ /[0-9a-f]{64}/) print $1":"$2}'|xargs docker rmi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment