Docker Community Forums

Share and learn in the Docker community.

How to remove <none> images after building

To remove all dangling Docker images:
sudo docker rmi $(sudo docker images -f “dangling=true” -q)

If run as root omit "sudo"
docker rmi $(docker images -f “dangling=true” -q)

Did you ever find a solution to this? I am running into the same problem and have tried everything mentioned here.

You cannot delete the intermediate images. This is a good article explaining it:


I try to clean space and It worked for me

You can use the following command to clean these components

docker system prune

will be showed the message below:

WARNING! This will remove:
	- all stopped containers
	- all volumes not used by at least one container
	- all networks not used by at least one container
	- all dangling images

Just say yes and keep calm. :slight_smile:


Use: docker image prune -f. More details here.


tl;dr - They cannot be deleted: save your new image, delete all the images and load it back

For anyone landing here, please read carefully Docker’s documentation and previous answers: as stated before ‘<none>:<none>’ images are intermediate images created during a build command and are parents of the newly created and, again, cannot be deleted.

Commands like docker image prune -f will not delete that images, I’ve personally tested every command mentioned on this post and the only way I’ve found to achieve that is using docker save/load:

docker save --output image.tar ImageID-or-Name
docker image prune -fa
docker load --input image.tar

OPTION 1: using error handling (send error to /dev/null)

docker rmi $(docker images --filter "dangling=true" -q --no-trunc) 2>/dev/null

docker rmi $(docker images --filter “dangling=true” -q --no-trunc) command will try to remove all dangled images. Once it is cleaned (no more image left), it will throw error as docker rmi require at least one image name/id.

2>/dev/null will direct any error message to null, so it will do nothing if all image is cleaned up.

OPTION 1: (no error)

You can also try cleaning only when dangled image is available using if condition to avoid any error. Something like below:

if [ "$(docker images -f "dangling=true" -q | awk '{print $3}' | sort -u)x" != "x" ]
       docker rmi $(docker images --filter "dangling=true" -q --no-trunc)

It is important to understand why you have intermediate untagged images showing as <none> <none> in order to avoid them since, as you have seen, you can’t remove them if they are in use.

The reason untagged images happen is because you built an image, then you changed the Dockerfile and built that image again and it reused some of the layers from the previous build. Now you have an untagged image which cannot be deleted because some of it’s layers are being used by a new version of that image.

The solution is to:

  • Delete the new version of the image
  • Delete the untagged image and
  • Rebuild the new version of the image so that it owns all of the layers.

You will be left with a single tagged image that contains all of the layers of the previous untagged images and the new image.


1 Like

It won’t work if the ‘docker images -a’ list with different order in the future, however , the command can delete “<none>” tagged images below.

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

Hi miniserver,
you can refer remove all images as below

You can refer link to details remove all none images

docker system prune will do the work. It will remove any unused images though. but I am sure, all worthy images should have been pushed to the registry so it should be okay to prune it, depending on your environment though.


If you are running Docker For Windows, the following will work:

echo off&for /f “delims=” %A in ('docker images -f “dangling=true” -q ') do docker rmi %A & echo on

To remove all images which aren’t associated with a running container:

docker image prune -a

The -a parameter is the crucial bit here.

If you want to force the action to occur without a confirmation prompt, you may add the -f parameter, like so:

docker image prune -af

Note: -af is the same as specifying -a and -f separately

If you are like me and keep trying out interactive terminal sessions on images all the time, you will see a lot of : images in the list. They are all linked to stopped containers that you used earlier. Cleanup containers and then cleanup images

docker container prune
docker image prune

This worked for me;

Shows all images, copy the ‘Image ID’ of the one you want to delete

sudo docker images

Command to delete, paste image id, without <> and hit enter

sudo docker rmi -f <$imageID>

##Visit your friends at;

On windows, create a new batch file and add the following command,
FOR /f “tokens=*” %%i IN (‘docker images -f “dangling=true” -q’) DO docker rmi %%i -f

1 Like

This works on my end. Removing all or unused images.

Docker rmi $(docker images -a -q)

docker rmi (docker images -f “dangling=true” -q )

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

Removing the double quotes from the dangling options solves the problem