forked from GhostWriters/DockSTARTer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker_prune.sh
More file actions
35 lines (32 loc) · 1.34 KB
/
Copy pathdocker_prune.sh
File metadata and controls
35 lines (32 loc) · 1.34 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
#!/usr/bin/env bash
set -Eeuo pipefail
IFS=$'\n\t'
docker_prune() {
local Title="Docker Prune"
Question="Would you like to remove all unused containers, networks, volumes, images and build cache?"
YesNotice="Removing unused docker resources."
NoNotice="Nothing will be removed."
local Command="docker system prune --all --force --volumes"
if run_script 'question_prompt' Y "${Question}" "${Title}" "${FORCE:+Y}"; then
if use_dialog_box; then
{
notice "${YesNotice}"
notice "Running: ${C["RunningCommand"]}${Command}${NC}"
eval "${Command}" || error "Failed to remove unused docker resources.\nFailing command: ${C["FailingCommand"]}${Command}"
} |& dialog_pipe "${DC["TitleSuccess"]-}${Title}" "${YesNotice}${DC["NC"]-}\n${DC["CommandLine"]-} ${Command}"
else
notice "${YesNotice}"
notice "Running: ${C["RunningCommand"]}${Command}${NC}"
eval "${Command}" || error "Failed to remove unused docker resources.\nFailing command: ${C["FailingCommand"]}${Command}"
fi
else
if use_dialog_box; then
notice "${NoNotice}" |& dialog_pipe "${DC[TitleError]}${Title}" "${NoNotice}"
else
notice "${NoNotice}"
fi
fi
}
test_docker_prune() {
run_script 'docker_prune'
}