Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why the "none" image appears in Docker and how can we avoid it

When I run the docker-compose build command to rebuild an image in Docker because I had changed something in Dockerfile, sometimes I get "none" image tags. How can we avoid this fact? I want to rebuild the image but the none image should not appear.

REPOSITORY  TAG            IMAGE ID            CREATED             SIZE magento2    latest         b4dce4dcbd4f        16 hours ago        516MB <none>      <none>         b4ffce2bf91e        16 hours ago        519MB <none>      <none>         a1aedb60c82a        17 hours ago        516MB <none>      <none>         ec9a14ae856c        20 hours ago        519MB <none>      <none>         ef8eba6874cc        23 hours ago        516MB <none>      <none>         0e53a8b8c303        23 hours ago        516MB php         7.1-apache     93e6fb4b13e1        3 weeks ago         369MB mysql       5.6.39         079344ce5ebd        7 months ago        256MB 
like image 248
Chen Hanhan Avatar asked Nov 09 '18 07:11

Chen Hanhan


People also ask

Why are there none images in docker?

The Bad <none>:<none>These images are the dangling ones, which can cause disk space problems. These <none>:<none> images are being listed as part of docker images and need to be pruned.

How do I get rid of none image?

When you build your images add “–rm” this should help with removing any intermediate and none images. [quote]When you build your images add “–rm” this should help with removing any intermediate and none images.

How do I remove all none Tager docker images?

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.

Can docker container exist without image?

Images can exist without containers, whereas a container needs to run an image to exist. Therefore, containers are dependent on images and use them to construct a run-time environment and run an application. The two concepts exist as essential components (or rather phases) in the process of running a Docker container.

Why does my Docker image have a tag of <none>?

It seems as though this <none> problem also occurs when you try to name your image with something containing a capital letter. For example I built an image with docker build -t myname/NewImage:0.1 . and this resulted in my image having a repo and tag of <none>. You built an image with docker build -t myname/NewImage:0.1 . more than one time.

Why does Docker image list show repository as repository and tag?

When you run docker image list it'll show repo/stuff as the repository and tag as the TAG Most of the times what I have observed is, this happens when we don't provide a tag name while building an image so if we run only docker build . , it vl create image with <none> as showed below:

What do the <none> images mean?

Since all these <none>:<none> images can be quite confusing as what they signify. These images are the dangling ones, which can cause disk space problems. These <none>:<none> images are being listed as part of docker images and need to be pruned.

What are dangling images in Docker images?

These images are the dangling ones, which can cause disk space problems. These <none>:<none> images are being listed as part of docker images and need to be pruned. (a dangling file system layer in Docker is something that is unused and is not being referenced by any images.


2 Answers

Below are some parts from What are Docker <none>:<none> images?

The Good <none>:<none>

These are intermediate images and can be seen using docker images -a. They don't result into a disk space problem but it is definitely a screen "real estate" problem. Since all these <none>:<none> images can be quite confusing as what they signify.

The Bad <none>:<none>

These images are the dangling ones, which can cause disk space problems. These <none>:<none> images are being listed as part of docker images and need to be pruned.

(a dangling file system layer in Docker is something that is unused and is not being referenced by any images. Hence we need a mechanism for Docker to clear these dangling images)

So,

  • if your case has to do with dangling images, it's ok to remove them with:

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

    There is also the option of docker image prune but the client and daemon API must both be at least v1.25 to use this command.

  • if your case has to do with intermediate images, it's ok to keep them, other images are pointing references to them.

Related documentation:

  • docker rmi
  • docker image rm
  • docker image prune
like image 193
tgogos Avatar answered Sep 28 '22 07:09

tgogos


In my experience most of the <none> images are held by temporary containers. Due to Docker architecture those containers are preserved even after they stop. You can verify how many stopped containers you have using

docker ps -a 

So to remove the <none> images you first need to remove the unneeded containers:

docker container prune docker image prune 

The above two commands can be abbreviated to

docker system prune 
like image 45
SnakE Avatar answered Sep 28 '22 05:09

SnakE