a handy tool to delete user specified docker images along with related containers which use these images
dockerrmi is similar with docker rmi. It works following these steps:
- determines if there are running containers which are using specified images,
- if true, try to stop these running containers by default, after all these containers are stopped,
- try to remove all containers which are using specified images,
- remove all specified images
- if there are running/stopped containers which are using specified images,
dockerrmiwill stop/remove those containers first, butdocker rmi -fdoesn't. - if there are running containers which are using specified images,
dockerrmiwill not result in dangling images, butdocker rmi -fdoes because it doesn't stop running containers
If you have Go installed, you can do:
- go get -u -v github.com/spf13/cobra/cobra
- go get -u -v github.com/spf13/viper
- go get -u -v github.com/bruceauyeung/dockerrmi
else you just need to download https://github.com/bruceauyeung/dockerrmi/raw/master/dockerrmi-linux-amd64, rename it to what you want and put it in $PATH
# dockerrmi --help
a handy tool to delete user specified docker images along with related containers which use these images
Usage:
dockerrmi [images] [flags]
Flags:
-s, --stoprunningcontainers whether or not stop those running containers that use specified image (default true)
-v, --version print version of dockerrmi
# dockerrmi busybox:latest
[Info] removed image 2b8fd9751c4c