Working with Docker images

In the previous chapter, we demonstrated the typical Hello World example using the
hello-world image. Now, there is a need for a closer observation of the output of the docker pull subcommand, which is the de facto command to download Docker images. Now, in this section, we will use the busybox image, one of the smallest but a very handy Docker image, to dive deep into Docker image handling:

If you pay close attention to the output of the docker pull subcommand, you will notice the Using default tag: latest text. The Docker image management capability (the local image storage on your Docker host or on a Docker image registry) enables storing multiple variants of the Docker image. In other words, you could use tags to version your images.

By default, Docker always uses the image that is tagged as latest. Each image variant can be directly identified by qualifying it with an appropriate tag. An image can be tag-qualified by adding a colon (:) between the tag and the repository name (<repository>:<tag>). For demonstration, we will pull the 1.24 tagged version of busybox as shown here:

Awesome! Isn't it? We are able to pull a specific version of busybox; in this case, it is busybox:1.24. The docker pull command also supports the -a option to download all available image variants. Use this option cautiously because you might end up filling up your disk space.

So far, we downloaded a few Docker images from the repository, and now they are locally available in the Docker host. You can find out the images that are available on the Docker host by running the docker images subcommand:

Evidently, we have three items in the preceding list and to gain a better understanding of these, we need to comprehend the information that is printed out by the docker images subcommand. Here is a list of the possible categories:

  • REPOSITORY: This is the name of the repository or image. In the preceding example, the repository names are hello-world and busybox.
  • TAG: This is the tag associated with the image, for example 1.24 and latest. One or more tags can be associated with one image.
  • IMAGE ID: Every image is associated with a unique ID. The image ID is represented using a 64 hex digit long random number. By default, the docker images subcommand will only show 12 hex digits. You can display all the 64 hex digits using the --no-trunc flag (for example: sudo docker images --no-trunc).
  • CREATED: This indicates the time when the image was created.
  • SIZE: This category highlights the virtual size of the image.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset