[SOLVED] Docker: How To Delete Images Tagged none – 1 Cool Tip?

[SOLVED] Docker: How To Delete Images Tagged none - 1 Cool Tip?
Share this post and Earn Free Points!

When we often rebuild the application image, which is marked with the same tag, e.g. latest [ How to delete images tagged none ] , we encounter the problem that our image registry (registry) will have many images that will be marked as <none>.

Introduction

Docker Images

Docker images are lightweight, standalone, and executable packages that contain everything an application needs to run, including the application code, libraries, dependencies, and runtime. They are used to create Docker containers, which are isolated environments that can run on any host with a Docker runtime.

Docker images are built using a series of instructions called a Dockerfile, which defines the steps required to create the image. These instructions can include commands to install packages, copy files, and set environment variables.

Docker images are stored in a registry, such as Docker Hub, which is a repository of images that can be accessed by users. Docker Hub includes a large number of pre-built images that can be used as-is or customized by adding additional instructions to the Dockerfile.

Docker <none> Image

A Docker image with a name of <none> indicates that the image was built without a specific name. This can happen if the FROM instruction in the Dockerfile does not specify a name for the image, or if the -t flag was not used when the image was built using the docker build command.

For example, the following Dockerfile would create an image with a name of <none>:

FROM python:3.8

COPY . /app
WORKDIR /app

RUN pip install -r requirements.txt

CMD ["python", "app.py"]

To give the image a specific name, you can specify the -t flag when building the image, like this:

docker build -t my-image .

Alternatively, you can specify the name of the image in the FROM instruction in the Dockerfile:

FROM python:3.8 as my-image

COPY . /app
WORKDIR /app

RUN pip install -r requirements.txt

CMD ["python", "app.py"]

Giving the image a specific name can make it easier to identify and manage the image, and it can also help you avoid confusion if you have multiple images with similar names.

Delete One By One -> How To Delete Images Tagged NONE

The problem we encounter then is a troublesome registry cleaner from this rubbish. Removing them one by one can give us a lot of nerves and we will lose a lot of time (it is such a “stupid” job). The best will be to have option like: Docker rmi none, but it’s not exists in Docker CLI.

Let’s look at the following repository list:

docker images
REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
python                      3                   0a3a95c81a2b        12 days ago         932MB
<none>                      <none>              871503ecbdc9        4 weeks ago         392MB
sonarqube                   latest              d7558a6a8598        2 months ago        479MB
redis                       5.0.5               63130206b0fa        2 months ago        98.2MB
postgres                    9.6                 61c59b9a763f        2 months ago        230MB
postgres                    latest              e2d75d1c1264        2 months ago        313MB
mysql                       5.7                 383867b75fd2        2 months ago        373MB

To delete the selected image, we can use the command:

docker image rm <IMAGE_ID>

In the example below, I will remove the redis image and I will leave for the next example.

# Delete redis image
docker image rm 63130206b0fa

pawel@pawel:~$ docker image rm 63130206b0fa
Untagged: redis:5.0.5
Untagged: redis@sha256:5dcccb533dc0deacce4a02fe9035134576368452db0b4323b98a4b2ba2d3b302
Deleted: sha256:63130206b0fa808e4545a0cb4a1f14f6d40b8a7e2e6fda0a31fd326c2ac0971c
Deleted: sha256:9476758634326bb436208264d0541e9a0d42e4add35d00c2a7408f810223013d
Deleted: sha256:0f3d9de16a216bfa5e2c2bd0e3c2ba83afec01a1b326d9f39a5ea7aecc112baf
Deleted: sha256:452d665d4efca3e6067c89a332c878437d250312719f9ea8fff8c0e350b6e471
Deleted: sha256:d6aec371927a9d4bfe4df4ee8e510624549fc08bc60871ce1f145997f49d4d37
Deleted: sha256:2957e0a13c30e89650dd6c00644c04aa87ce516284c76a67c4b32cbb877de178

Bulk Operation Of ‘How To Delete Images Tagged none <none>’?

To delete all images with tag and repository use the command below (Docker remove all none images):

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

As a result of the command you will receive information about what has been deleted:

Deleted: sha256:871503ecbdc9f2f2bb2989af6440d34b0eef684b730d317680a8440813f321b5
Deleted: sha256:eb22964fbb062e908432240a2d12a448e75db2081481422c2908ec7875074a00
Deleted: sha256:bdc87704af3a50bd53ae32edef6c7f020b8f144c7ab9b227a9905223a0e0885f
Deleted: sha256:d0cddd997d27bd75a0b75d36733e4350e5750f0d0182cd634801c579e9aba915
Deleted: sha256:1781e4eca03220934d1646f64a6d3775b935c6db2fb00474b5c8d9844e8faa1f

You can now check again if the images have actually been deleted using the command:

docker images

Summary

That’s all about how to how to delete images tagged none / <none>!

Could You Please Share This Post? 
I appreciate It And Thank YOU! :)
Have A Nice Day!

How useful was this post?

Click on a star to rate it!

Average rating 4.9 / 5. Vote count: 1905

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?