stop_container_count=$(docker ps -a | grep "Exited" | awk '{print $1 }' | wc -l ); \ if [ $stop_container_count -gt 0 ] ; \ then \ docker stop $(docker ps -a | grep "Exited" | awk '{print $1 }'); \ echo 'stop ok'; \ else \ echo 'stop ok'; \ fi rm_container_count=$(docker ps -a | grep "Exited" | awk '{print $1 }' | wc -l ); \ if [ $rm_container_count -gt 0 ] ; \ then \ docker rm $(docker ps -a | grep "Exited" | awk '{print $1 }'); \ echo 'rm ok'; \ else \ echo 'rm ok'; \ fi rmi_image_count=$(docker images | grep "none" | awk '{print $3}' | wc -l ); \ if [ $rmi_image_count -gt 0 ] ; \ then \ docker rmi $(docker images | grep "none" | awk '{print $3}'); \ echo 'rmi ok'; \ else \ echo 'rmi ok'; \ fi
标签:count,ok,清理,echo,awk,print,镜像,docker From: https://www.cnblogs.com/wafulo/p/17275324.html