Skip to content

Instantly share code, notes, and snippets.

@bjoern-r
Created June 8, 2016 08:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoern-r/b1c2f2260b9d6d75dc2d7512eb6027d2 to your computer and use it in GitHub Desktop.
Save bjoern-r/b1c2f2260b9d6d75dc2d7512eb6027d2 to your computer and use it in GitHub Desktop.
cleanup local docker images
#!/bin/bash
echo "About to remove the following images:"
docker images | awk '/^<none>/ {print}'
echo "press <ctrl+c> to abort! <enter> to continue"
read foo
docker images | awk '/^<none>/ {print $3}' | xargs --no-run-if-empty docker rmi
@bjoern-r
Copy link
Author

bjoern-r commented Jun 8, 2016

example output

user@host:~/$ docker-cleanup 
About to remove the following images:
<none>                      <none>              8bae3aa2cf3d        19 hours ago        637 MB
<none>                      <none>              1d91d1f3ef4a        20 hours ago        661.5 MB
<none>                      <none>              344a8af56dd0        20 hours ago        661.5 MB
<none>                      <none>              8e70c364aa10        47 hours ago        658.3 MB
<none>                      <none>              ba38b84edf2e        47 hours ago        639 MB
<none>                      <none>              ccdf2b9b319f        47 hours ago        767.3 MB
<none>                      <none>              bd4bab9eb074        5 days ago          571.7 MB
press <ctrl+c> to abort! <enter> to continue

Deleted: sha256:8bae3aa2cf3dc463a78fc714d6f61efb34a8aad32d9769271d8bb861449000e4
...
Deleted: sha256:aab0f67406a437132e493cd64cfaded86a8d514390363a03d3599cd9f9d4467a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment