Add docker cleanup script
Project: http://git-wip-us.apache.org/repos/asf/couchdb-ci/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-ci/commit/7fa91cae Tree: http://git-wip-us.apache.org/repos/asf/couchdb-ci/tree/7fa91cae Diff: http://git-wip-us.apache.org/repos/asf/couchdb-ci/diff/7fa91cae Branch: refs/heads/master Commit: 7fa91caead0481b5a2dc916f52a1ff0c7a0c7309 Parents: 51f2988 Author: Joan Touzet <[email protected]> Authored: Thu Mar 16 14:44:55 2017 -0700 Committer: Joan Touzet <[email protected]> Committed: Thu Mar 16 14:44:55 2017 -0700 ---------------------------------------------------------------------- bin/cleanup-docker.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-ci/blob/7fa91cae/bin/cleanup-docker.sh ---------------------------------------------------------------------- diff --git a/bin/cleanup-docker.sh b/bin/cleanup-docker.sh new file mode 100755 index 0000000..dc114ac --- /dev/null +++ b/bin/cleanup-docker.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +echo WARNING! This script will delete all stopped containers! +read -n1 -r -p "Press any key to continue..." key +echo + +# Delete all stopped containers +docker rm $(docker ps -aq --filter status=exited) 2&>/dev/null + +# Delete all untagged or dangling images +docker rmi $(docker images -q -f dangling=true) 2&>/dev/null + +# Clean up dangling volumes, if any +docker volume rm $(docker volume ls -qf dangling=true) 2&>/dev/null +
