Commit 6367cd13 authored by Jeff Grafton's avatar Jeff Grafton

Only remove day+ old containers in Jenkins daily cleanup

parent 3b09c641
...@@ -9,8 +9,11 @@ ...@@ -9,8 +9,11 @@
gcloud components update gcloud components update
gcloud components update alpha gcloud components update alpha
gcloud components update beta gcloud components update beta
# Select only exited or dead containers that weren't created today.
# A sort of work-around for https://github.com/kubernetes/kubernetes/issues/24661
containers_to_remove=($(docker ps -a -f 'status=exited' -f 'status=dead' --format='{{.CreatedAt}}\t{{.ID}}' | grep -v ^$(date +%Y-%m-%d) | cut -f2 || true))
# Copied from http://blog.yohanliyanage.com/2015/05/docker-clean-up-after-yourself/ # Copied from http://blog.yohanliyanage.com/2015/05/docker-clean-up-after-yourself/
docker rm -v $(docker ps -a -q -f 'status=exited' -f 'status=dead') || true docker rm -v "${containers_to_remove[@]:+${containers_to_remove[@]}}" || true
docker rmi $(docker images -q -f 'dangling=true') || true docker rmi $(docker images -q -f 'dangling=true') || true
docker run -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker:/var/lib/docker --rm martin/docker-cleanup-volumes docker run -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker:/var/lib/docker --rm martin/docker-cleanup-volumes
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment