Running the commands docker images
and docker images -a
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 the images tagged <none>
of any importance? If not: why do they come with the tagged images I pulled? Do the sizes add up or are they just a repition? If so, can I delete them without any effect on my work?
These images occur when a new build of an image takes the repo:tag away from the IMAGE ID, leaving it untagged. A warning will be issued if trying to remove an image when a container is presently using it. By having this flag it allows for batch cleanup.
A tag is a reference to an image. Multiple tags may refer to the same image. If you reassign a tag that is already used, then the original image will lose the tag, but will continue to exist (it will still be accessible by its image ID, and other tags might refer to it). They have both a name and a tag.
Build an Image with Multiple Docker Tags. In Docker, we can also assign multiple tags to an image. Here, we'll use the docker build command to assign multiple tags to an image in a single command.
3.2. If we do not want to find dangling images and remove them one by one, we can use the docker image prune command. This command removes all dangling images. If we also want to remove unused images, we can use the -a flag.
The image files are independent, and combine via unionfs magic to form a running container. The images you care about are often tagged with memorable names. You can delete the unused images, i.e. those not contributing to any image you care about. I do it this way in bash:
function docker_rm_unnamed_images {
sudo docker rmi $(sudo docker images | grep '^<none>' | awk '{print $3}')
}
You can think of a docker image as a stack of 'layers'. Each Dockerfile command adds an additional layer to the image. It's important to realize that each of those commands creates a separate image file. So the Dockerfile
FROM foo
RUN a
RUN b
RUN c
would be a stack of
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 composed of multiple other layers, so your final image is a stack of 4 or more images. Each of those image files lives in your docker image registry. Most of them are unnamed, because they correspond to a RUN command, for example. Each of the image files 1-4 are probably fairly small (unless they correspond to a yum install p1 .. p100 for example). Together they make up the file system of the container that you ultimately run.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With