Skip to content

Instantly share code, notes, and snippets.

@pzelnip
Last active June 9, 2018 01:49
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 pzelnip/40da3bf80876c2cdb5809d8a3bd9ee97 to your computer and use it in GitHub Desktop.
Save pzelnip/40da3bf80876c2cdb5809d8a3bd9ee97 to your computer and use it in GitHub Desktop.
Docker interactive image deletion
#!/bin/bash
select x in `docker images --format '{{.ID}}--{{.Repository}}/{{.Tag}}'` ; do docker rmi "${x%--*}"; done
@pzelnip
Copy link
Author

pzelnip commented Jun 8, 2018

Allows you to interactively in a shell delete local Docker images.

Running it:

$ docker_image_delete.sh
 1) 18bfe820e13a--microsoft/dotnet/1.1-sdk
 2) 452a96d81c30--ubuntu/latest
 3) c9d990395902--ubuntu/16.04
 4) 2dea9e73d89e--nginx/1.13.11-alpine
 5) 9cc35bb87070--ruby/2.3
#? 1
Untagged: microsoft/dotnet/1.1-sdk
Deleted: sha256:17993168784ac66b1274d8f60b5d0b0f90512bd1e733dd8092294d9a6dd49ab3
Deleted: sha256:e59553776430ec15c5b927c682214351db83fd757c807b4915edbac1120aa983
....
#? 3
Untagged: ubuntu/16.04
Deleted: sha256:17993168784ac66b1274d8f60b5d0b0f90512bd1e733dd8092294d9a6dd49ab3
Deleted: sha256:e59553776430ec15c5b927c682214351db83fd757c807b4915edbac1120aa983
...

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