If the images in Docker were not tagged, are they used at all or just orphans?

Running the docker images and docker images -a commands results in the following outputs:

 $ docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE ubuntu 14.04 9cbaf023786c 2 days ago 192.8 MB $ docker images -a REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE ubuntu 14.04 9cbaf023786c 2 days ago 192.8 MB <none> <none> 03db2b23cf03 2 days ago 192.8 MB <none> <none> 8f321fc43180 2 days ago 192.8 MB <none> <none> 6a459d727ebb 2 days ago 192.8 MB <none> <none> 2dcbbf65536c 2 days ago 192.8 MB <none> <none> 97fd97495e49 2 days ago 192.6 MB 

Are images tagged with <none> important? If not: why do they come with labeled images that I pulled out? Can dimensions add up or is it just a repetition? If so, can I remove them without any consequences for my work?

+6
source share
2 answers

Image files are independent and combined using unionfs magic to create a running container. The images you care about are often tagged with memorable names. You can delete unused images, i.e. Those that do not contribute to any image that interests you. I do it like this in bash:

 function docker_rm_unnamed_images { sudo docker rmi $(sudo docker images | grep '^<none>' | awk '{print $3}') } 

You can present the docker image as a stack of "layers". Each Dockerfile command adds an extra layer to the image. It is important to understand that each of these commands creates a separate image file. So Dockerfile

 FROM foo RUN a RUN b RUN c 

will be a stack

 image=1 (possibly pulled from the foo registry) image=2 (after applying a to image 1) image=3 (after applying b to image 2) image=4 (after applying c to image 3) 

It is likely that the foo image was made up of several other layers, so your final image is a stack of 4 or more images. Each of these image files is located in your docker image registry. Most of them are unnamed because they correspond to the RUN command, for example. Each of the image files 1-4 is probably quite small (if they do not match, for example, the installation yum install p1 .. p100). Together they make up the container file system that you end up executing.

+8
source

To delete all untagged images, additional parameters are required:

 docker rmi $(sudo docker images -a | grep '^<none>' | awk '{print $3}') 

option '-a': show all images, including unlabeled images

+2
source

Source: https://habr.com/ru/post/976826/


All Articles