-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker-clean
executable file
·26 lines (22 loc) · 1.03 KB
/
docker-clean
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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