How to remove <none> images after building successfull

Viewed 3424

After I build my image, there are a bunch of images. When I try to delete them I get “image has dependent child images” errors. Is there anyway to clean this up?

These do NOT work:

docker rmi $(docker images -q)
docker rmi $(docker images | grep “^” | awk “{print $3}”)
docker rmi $(docker images -f “dangling=true” -q)
3 Answers
docker rmi `docker images | grep "<none>" | awk {'print $3'}`

Try this:

docker rmi $(docker images | grep none | awk '{print $3}')

You can add -f to force image removal but I do not recommend doing so. If you cannot remove the images with the command above that means it is in partially in use or stopped containers are using the images you are trying to remove.

You can always check the stopped or Existed containers with

docker ps -a

Here, the Status column will indicate the container status.

docker rmi docker images -a | grep "<none>" | awk {'print $3'}

Adding -a is required.

Related