Skip to content

Commit

Permalink
Added docker-clean
Browse files Browse the repository at this point in the history
Taken from
https://github.com/gnarea/shell-tools/blob/aef8f5cde2966b93fe4eda27d57769b544862546/docker-clean

As the original author, I am relicensing this work under the BSD
License.

INF-97
  • Loading branch information
Gustavo Narea committed Jul 27, 2017
1 parent b19a54c commit 3e3ee19
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ docker-dev build webapp
```

`docker-dev` supports autocompletion in a Bash session.

## `docker-clean`

This command will remove **all** your Docker resources (e.g., containers,
volumes), except for images created in the past week.
26 changes: 26 additions & 0 deletions docker-clean
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
##############################################################################
#
# Copyright (c) 2017, 2degrees Limited.
# Copyright (c) 2017, Gustavo Narea.
#
# This file is part of docker-dev
# <https://github.com/2degrees/docker-dev>, which is subject
# to the provisions of the BSD at
# <http://dev.2degreesnetwork.com/p/2degrees-license.html>. A copy of the
# license should accompany this distribution. THIS SOFTWARE IS PROVIDED "AS IS"
# AND ANY AND ALL EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT
# NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST
# INFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
#
##############################################################################
. "$(dirname $BASH_SOURCE)/_bootstrap.sh"


docker ps --quiet --all | \
xargs --no-run-if-empty docker rm --force --volumes >> /dev/null

docker system prune --force

docker images | egrep '(weeks|months|years) ago' | awk '{ print $3 }' | \
xargs --no-run-if-empty docker rmi --force >> /dev/null

0 comments on commit 3e3ee19

Please sign in to comment.