Last active
September 10, 2015 19:27
-
-
Save anokun7/9474a051937cdd712bdf to your computer and use it in GitHub Desktop.
To remove all docker images or containers directly from commandline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Need to force | |
# Ideally run this after removing the containers so that the images are not being used | |
for i in $(docker images | tail -n +2 | awk '{ print $3 }'); do docker rmi -f $i ; done | |
# Need to stop the container before removing it | |
# Instead of 'docker stop', you can also run 'docker kill'. | |
for i in $(docker ps -a | tail -n +2 | awk '{ print $1 }'); do docker stop $i && docker rm $i ; done |
for i in $(docker ps -aq); do docker stop $i && docker rm
Much quicker / nifitier
docker rm -f $(docker ps -qa) && docker rmi -f $(docker images -q)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Need to force
Ideally run this after removing the containers so that the images are not being used
for i in $(docker images -q); do docker rmi -f $i ; done
Need to stop the container before removing it
Instead of 'docker stop', you can also run 'docker kill'.
for i in $(docker ps -aq); do docker stop $i && docker rm $i ; done