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,
dockerrmi
will stop/remove those containers first, butdocker rmi -f
doesn't. - if there are running containers which are using specified images,
dockerrmi
will not result in dangling images, butdocker rmi -f
does 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