Does what it says on the tin. I'm using fish so my one liner looks like this:
docker rm (docker ps -a -q) && docker rmi -f (docker image ls -q)
If you're running a more standard shell like bash, you'll probably need some $
s in there:
docker rm $(docker ps -a -q) && docker rmi -f $(docker image ls -q)
It's pretty simple - docker rm
removes containers. It accepts a list of container Ids. docker ps -a -q
lists all containers in quiet mode - so just the container Ids.
The logic is the same for removing images - I've thrown in the f
force flag for good measure, and I've used &&
to concatenate two commands onto one line.
This will error out if you have no containers. Be warned.
Top comments (0)