How To Remove Docker Images, Containers

Posted on June 1, 2017
Tags: docker

Remove docker images

List: docker images -a
Remove: docker rmi Image Image

Remove dangling images

List: docker images -f dangling=true
Remove: docker rmi $(docker images -f dangling=true -q)

Remove all images

List: docker images -a
Remove: docker rmi $(docker images -a -q)

Remove all exited containers

List: docker ps -a -f status=exited
Remove: docker rm $(docker ps -a -f status=exited -q)

Remove containers using more than one filter

List: docker ps -a -f status=exited -f status=created
Remove: docker rm $(docker ps -a -f status=exited -f status=created -q)

Stop and remove all containers

List: docker ps -a
Remove: docker stop $(docker ps -a -q)
Remove: docker rm $(docker ps -a -q)