Skip to content

Commit

Permalink
Scripts: Add tool to cleanup docker resources.
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoxq authored and lianglia-apollo committed Mar 9, 2018
1 parent 650ffc9 commit 4082c0d
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions docker/scripts/cleanup_resources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

###############################################################################
# Copyright 2018 The Apollo Authors. All Rights Reserved.
#
# Licensed 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.
###############################################################################

if [ ! -z ${DOCKER_IMG} ]; then
echo "This script is expected to be run on host instead of the container."
echo "Please exit."
exit 1
fi

# Credit to https://gist.github.com/bastman/5b57ddb3c11942094f8d0a97d461b430
echo "Cleanup containers..."
docker rm $(docker ps -qa --no-trunc --filter "status=exited")

echo "Cleanup images..."
docker rmi $(docker images --filter "dangling=true" -q --no-trunc)

echo "Cleanup volumes..."
docker volume rm $(docker volume ls -qf dangling=true)

0 comments on commit 4082c0d

Please sign in to comment.