forked from docker-library/python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprune.sh
More file actions
executable file
·27 lines (25 loc) · 718 Bytes
/
Copy pathprune.sh
File metadata and controls
executable file
·27 lines (25 loc) · 718 Bytes
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
#!/usr/bin/env bash
set -Eeuo pipefail
docker container prune --force
docker volume prune --force
# rmi everything minus a whitelist so this can be kinder on Windows (where base images are large and take time to clone)
images="$(
docker image ls --no-trunc --digests --format '
{{- $hasTag := ne .Tag "<none>" -}}
{{- $hasDigest := ne .Digest "<none>" -}}
{{- if (or $hasTag $hasDigest) -}}
{{- .Repository -}}
{{- if $hasTag -}}
{{- ":" -}}
{{- .Tag -}}
{{- end -}}
{{- if $hasDigest -}}
{{- "@" -}}
{{- .Digest -}}
{{- end -}}
{{- else -}}
{{- .ID -}}
{{- end -}}
'
)"
grep -vE '^mcr[.]microsoft[.]com/windows(/[^:@]+)?:' <<<"$images" | xargs -rt echo docker image rm