-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsded.sh
More file actions
executable file
·54 lines (48 loc) · 1.05 KB
/
sded.sh
File metadata and controls
executable file
·54 lines (48 loc) · 1.05 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env bash
# Mini superset of the docker command that help to cleanup disk space eat by docker
# Traps any error (see https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html)
set -e -o pipefail -u
dkrshelp () {
cat <<EOT
Usage: $(basename "$0") [h] [l,i,od,du] -- cleanup disk space eat by docker
where:
h: show this help text
l: see list of running containers
i: see list of stored images
od: delete orphaned and dangling volumes
du: delete dangling and untagged images
p: `official` docker cleanup method; delete stopped containers, and volumes and networks that are not used by containers
EOT
exit 0
}
argc=${#}
if [[ ${argc} -eq 0 ]]; then
dkrshelp
fi
cmd=${1}
case ${cmd} in
h)
dkrshelp
;;
-h)
dkrshelp
;;
l)
docker ps
;;
i)
docker images
;;
od)
docker volume rm $(docker volume ls -qf dangling=true)
;;
du)
docker rmi $(docker images -q -f dangling=true)
;;
p)
docker system prune -a
;;
*)
dkrshelp
;;
esac