awk和xargs清除docker 容器、镜像

1.删除为 none 的镜像

docker images | grep <none> | awk '{print $3}' | xargs docker rmi -f

2.删除已经停止的容器

docker images | grep Exited | awk '{print $1}' | xargs docker rm  -f

print $n  是指定查询的容器id

 
原文地址:https://www.cnblogs.com/ming-blogs/p/13220372.html