Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker remove <none> TAG images

Tags:

docker

People also ask

How do I remove untagged docker images?

You can remove an image with docker rmi command, passing the name of the image you want to remove. This will remove the image. Sometimes when testing and developing, some images become dangling, which means untagged images. They can always be safely removed to free disk space.

How do I remove all docker images with none tag?

docker image prune removes all dangling images (those with tag none). docker image prune -a would also remove any images that have no container that uses them.

How do I remove docker images?

To remove the image, you first need to list all the images to get the Image IDs, Image name and other details. By running simple command docker images -a or docker images . After that you make sure which image want to remove, to do that executing this simple command docker rmi <your-image-id> .

What are untagged docker images?

From their documentation. This will display untagged images, that are the leaves of the images tree (not intermediary layers). These images occur when a new build of an image takes the repo:tag away from the IMAGE ID, leaving it untagged.


You can try and list only untagged images (ones with no labels, or with label with no tag):

docker images -q -a | xargs docker inspect --format='{{.Id}}{{range $rt := .RepoTags}} {{$rt}} {{end}}'|grep -v ':'

However, some of those untagged images might be needed by others.

I prefer removing only dangling images:

docker rmi $(docker images --filter "dangling=true" -q --no-trunc)

As I mentioned for for docker 1.13+ in Sept. 2016 in "How to remove old and unused Docker images", you can also do the image prune command:

docker image prune

That being said, Janaka Bandara mentions in the comments:

This did not remove <none>-tagged images for me (e.g. foo/bar:<none>); I had to use docker images --digests and docker rmi foo/bar@<digest>

Janaka references "How to Remove a Signed Image with a Tag" from Paul V. Novarese:

# docker images
REPOSITORY               TAG                 IMAGE ID            CREATED             SIZE
pvnovarese/mprime        latest              459769dbc7a1        5 days ago          4.461 MB
pvnovarese/mprime        <none>              459769dbc7a1        5 days ago          4.461 MB

Diagnostic Steps

You can see the difference in these two entries if you use the --digests=true option (the untagged entry has the Docker Content Trust signature digest):

# docker images --digests=true
REPOSITORY               TAG                 DIGEST                                                                    IMAGE ID            CREATED             SIZE
pvnovarese/mprime        latest              <none>                                                                    459769dbc7a1        5 days ago          4.461 MB
pvnovarese/mprime        <none>              sha256:0b315a681a6b9f14f93ab34f3c744fd547bda30a03b55263d93861671fa33b00   459769dbc7a1        5 days ago     

Note that Paul also mentions moby issue 18892:

After pulling a signed image, there is an "extra" entry (with tag <none>) in "docker images" output.
This makes it difficult to rmi the image (you have to force it, or else first delete the properly-tagged entry, or delete by digest.


docker images | grep none | awk '{ print $3; }' | xargs docker rmi

You can try this simply


docker image prune removes all dangling images (those with tag none). docker image prune -a would also remove any images that have no container that uses them.

The difference between dangling and unused images is explained in this stackoverflow thread.


Just run this command:

docker image prune --filter="dangling=true"

According to the docker documentation you can list only untagged (dangling) images with

$ docker images -f "dangling=true"

and redirect them to docker rmi command like that:

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

Notice -q param thats only show numeric IDs of containers.


Remove images which have none as the repository name using the following:

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

Remove images which have none tag or repository name:

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