DCA - 03 - Docker Images and Tags

Jarret B

Well-Known Member
Staff member
May 22, 2017
Reaction score
When dealing with Docker, you will need to have images to work with.

A Docker image is a package of software, which is executable, and includes everything you need to run the application or Operating System in the image.

Each image will have an image ID and a Tag usually refers to a version or a variant. For example, for Ubuntu, the tag can be the version by name, such as 'bionic', 'jammy', etc.

You will need to manage the images and download them to the local server. To get the image you need, you will need to find one first.

Searching for an Image

Before you download an image, you need to find the image you want. Let's say we want to download an Ubuntu image. From a command line, you can use the search command 'docker search <name>'. So, to get Ubuntu, we'd use the command 'docker search ubuntu'. The result is quite extensive. Most of these will not work for us, but we can limit the output.

In the previous listing, there should be a ‘Stars' column. These are a type of rating to let you know which is the most popular. If we wanted to sort out the list by only those that have a rating, we can use the command 'docker search -f stars=1 ubuntu'. In the command, we are filtering the column labeled 'stars' to a minimum value of '1'.

Two other columns are 'Official' and 'Automated'. The 'owner' of the image put the 'Official' images up. 'They label automatically updated images as 'Automated'. If you wanted only 'Official' images and those with stars, the command is 'docker search -f stars=1 -f is-official=true ubuntu'.

Now, the problem with the results is that you do not get all the tags listed. If you want the tags, go to ' https://hub.docker.com/search?image_filter=official&q=&type=image' and at the top, type in your search string, such as 'ubuntu'.

After a search, the command displays the results. Select the image you are interested in downloading. It should list the top one as a 'Docker Official Image'. Once the new page loads, just a little down should be the section 'Supported Tags'. This area should list what you need if you do not need the latest version. In this example, the section lists:

  • 18.04, bionic-20221019, bionic
  • 20.04, focal-20221019, focal
  • 22.04, jammy-20221101, jammy, latest
  • 22.10, kinetic-20221101, kinetic, rolling
  • 14.04, trusty-20191217, trusty
  • 16.04, xenial-20210804, xenial
You can see here that at the time I wrote this, 'jammy' is listed as the 'latest'. But if you wanted to get the image specifically for 'bionic', you need to know the specific tag of '18.04', 'bionic-20221019' and 'bionic'. Any tag will work for that specific OS version.

Once you have found the image you were searching for, it is time to get it on your system.

Downloading an Image

Once we have found an image we want to get, we need the Image Name and the Tag. If we do not specify a Tag, then it defaults to the 'latest' version.

So, to download the image, we use the command 'docker pull <image-name>:<tag>'. In our case, as an example, we'll use the command 'docker pull ubuntu:bionic'.

The time to download an image depends on the size of the image. If you issue the command on an image that is already local, it will see if the image has an update and will download the image if there is a newer image with the same tag.

Once you download an image, you can use the command 'docker images' to see the list of all local images. The command will show the Repository Name, Tag, Image ID, Created and size. Figure 1 shows an example.

Figure 01.JPG


You can see the SHA256 Digest for the Images by running 'docker images --digests'.

In most cases, wit has truncated the Image ID to show only the first 12 characters of the full Image ID. To see the full Image ID, run 'docker images --no-trunc'. If you only want to list the Image IDs, use the command 'docker images -q'.

Let's say you want to download all versions of Ubuntu. Just use the parameter '-a', like in 'docker pull -a ubuntu'. Once the command downloads all the images, you can remove the ones you do now want.

To remove an image, use the command 'docker image rm <image-name>:<tag>'. For example, if you downloaded 'ubuntu:jammy' by mistake, the command to remove it is 'docker image rm ubuntu:jammy'.

NOTE: The command is a singular 'image' as in 'docker image' and not 'docker images'.

You can create a pointer from a custom named image to an existing image. If you do this, the image exists once, but is accessible by two different names.

For example, if we have 'ubuntu:bionic' we can name is 'os:18' with the command 'docker tag ubuntu:bionic os:18'. I show the result in Figure 2. Looking at Figure 2, you can see that it shows both images, but each has the same Image ID since they are the same file. The command is the same as 'docker image tag <source-image-name>:<source-tag> <target-image-name>:<target:tag>'.

Figure 02.JPG


Once downloaded, it is good to know the commands that you can use on the image that is now on your system.

Docker Image Commands

We covered two of the 'docker image' commands, but we'll go over more.

Deleting images with the 'rm' keyword, we can delete one of the two images that are the same, and the other will remain. Such as, 'docker image rm ubuntu:bionic' or 'docker rm os:18' will remove the link, but since the other link remains, it does not delete the image file.

To list the local Docker images, you can use the command 'docker images' or 'docker image ls'.

We can remove any dangling images with the command 'docker image prune'. The command is only beneficial after you build images.

There are other commands that we will cover when we get to the topics that the commands are most useful.

With everything we can do with an image, it is also good to move an image to another system.

Saving and Restoring Docker Images Across Systems

If you have an image on a system that you want to move or copy to another system, then you need to back it up, copy it to the other system, and then restore it.

Let's say we had an image we built and we wanted to copy to a second system. We'll use the image information of 'os:18' as an example.

The command to save the image is 'docker image save os:18 > os18.tar'. The output filename can have any legal name that is usable on the source and target machine.

You can copy the 'tar' file by whatever means you want; such as, USB Drive, SCP, etc.

If I want to restore it back to my local system, I can remove the existing image pointer with the command 'docker image rm os:18'. Running 'docker images', we can see it is gone.

Once on the other system, there are two methods to restore the image.

The first method will replace the image just as it was, with the same name and tag. The command is 'docker load <os18.tar'. Running 'docker image ls', you can see it is back and has the same Image ID and exists as a pointer again.

The second method allows you to change the name and tag to what you want. The command is 'docker input <tar-file> <new-name>:<new-tag>'. So, if I used the command 'docker image import os18.tar ubuntu:beaver'. We can see that a new image with a new Image ID and time stamp has been created, as shown in Figure 3.

Figure 03.JPG


Images contain information that we can look at if we need more info. Sometimes the information can be useful, sometimes not. Just in case we need it, let's check it out.

Inspecting Images

Information stored in the image may be beneficial if it exists, but it may not exist in the image.

So, let's look just so you know how to do it.

The command is 'docker image inspect <image-name>:<tag>'. The information will be output to the screen, but you can redirect it to a file.

Let's look at an example, such as the command 'docker image inspect ubuntu:latest'. The result is:

"Id": "sha256:a8780b506fa4eeb1d0779a3c92c8d5d3e6a656c758135f62826768da458b5235",
"RepoTags": [
"RepoDigests": [
"Parent": "",
"Comment": "",
"Created": "2022-11-02T18:25:55.892262049Z",
"Container": "25b6562da9dcd64edcdd0134d3b6d9059fcfa7bfde49a8507bdace33ad8462d6",
"ContainerConfig": {
"Hostname": "25b6562da9dc",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"Cmd": [
"#(nop) ",
"CMD [\"bash\"]"
"Image": "sha256:1a63d0d85f9299001d53471efa6e2828526d384278096a48fd1840b9be130d36",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {}
"DockerVersion": "20.10.12",
"Author": "",
"Config": {
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"Cmd": [
"Image": "sha256:1a63d0d85f9299001d53471efa6e2828526d384278096a48fd1840b9be130d36",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": null
"Architecture": "amd64",
"Os": "linux",
"Size": 77792502,
"VirtualSize": 77792502,
"GraphDriver": {
"Data": {
"MergedDir": "/var/lib/docker/overlay2/926add230151e0182c90c7ff03662662295226db845682cbc3f0cec8689cce7d/merged",
"UpperDir": "/var/lib/docker/overlay2/926add230151e0182c90c7ff03662662295226db845682cbc3f0cec8689cce7d/diff",
"WorkDir": "/var/lib/docker/overlay2/926add230151e0182c90c7ff03662662295226db845682cbc3f0cec8689cce7d/work"
"Name": "overlay2"
"RootFS": {
"Type": "layers",
"Layers": [
"Metadata": {
"LastTagTime": "0001-01-01T00:00:00Z"

To represent the keys, such as 'Architecture', it is a root level key. Meaning that it is not contained in another key. To represent the root level key 'Architecture', we designate it as '.Architecture'.We can see the value of the 'Architecture' key with the command:

docker inspect ubuntu:latest --format '{{.Architecture}}'

Let's look at a third level key, such as 'Architecture.Data.WorkDir'. This is the location of the image file on the system:

docker inspect ubuntu:latest --format '{{.GraphDriver.Data.WorkDir}}'

My result is '/var/lib/docker/overlay2/926add230151e0182c90c7ff03662662295226db845682cbc3f0cec8689cce7d/work'. If I go to this folder on my Docker Server, I should find the folder structure of the image. I can add files here if needed. When I run the image interactively, I should find any folder or files placed there.

Do not make any major changes here. You could cause your image to be unstable.

If you have multiple images linked, they have the same 'Image ID', then you can find linked images by checking the 'RepoTags' key. For example, the image 'os:18' has over one image linked. So, with the command 'docker image os:18 --format {{.Repotags}}', I get an output of '[os:18 ubuntu:bionic]'. This shows that the images 'os:18' and 'ubuntu:bionic' are the same image.


The article should give you a good basis for finding and downloading images. Once you have downloaded images, then you can easily manage or manipulate the images as you need.

Be aware of these commands, since we will continually use some of these when using Docker.

Good day Good Sir,

I am in hopes replying to this thread is not entirely out of line. If it is, please inform me, I will delete it as soon as physically possible.

This messages intent is simply to say `Thank You VERY Much!` Some things to the new are only complicated until explained simply. That well explained introduction answered a slew of questions I have not had time for research to quell. A brief read, fortunately your compacted education resolved the unanswered. I have been bitten, now I must learn even more. In years to come. when asked. I will just blame...... YOU.

I imagine your skillful art of tutor was born the day your first was. So many progeny listed without a single complaint?? A long-suffering guardian could only have been a loving instructor.

Or Damn good brainwash.

Apologies for the ramble and Thank You once again.

Members online