Docker Community Forums

Share and learn in the Docker community.

Command to remove all unused images

See also New Data Management commands

1 Like

Super duper awesome, such a welcome addition to Docker.

docker system prune


docker image prune

should do the trick next version!


If someone uses earlier version

docker rmi $(docker images -q -f "dangling=true")

Thanks. Very helpful!

Cleaning up after Docker right now is as easy as issuing

docker system prune

This works starting with version 1.25, you can read more here.

Previously, or if you prefer to have a bit more control, you could use the following:

$ docker rm -v $(docker ps -aq -f 'status=exited')
$ docker rmi $(docker images -aq -f 'dangling=true')

# ATTENTION: this will also remove volumes of docker-compose if the containers are barely stopped
$ docker volume rm $(docker volume ls -q -f 'dangling=true')

If you want more details about cleaning up after Docker, check out this article.

I used these to clean images

sudo docker rmi -f $(sudo docker images | grep “” | awk “{print $3}”)

I think this is similar

docker images -f "dangling=true" --format "{{.ID}}" | xargs docker rmi -