Docker Images

We have set up Docker and introduced the Docker Hub in the previous Discovering Docker posts. In this post we will discuss Docker images and how they are used and then in the next post we will create a Docker image.

The Docker image is simply a file that will have multiple layers. They are used to execute code within a Docker container. Each one will be built from instructions based on an executable version of an application and will rely on the Docker host operating system kernel. The image will become one, or multiple, instances of a container when it is run by a Docker user.

docker run hello-world

  • docker – a specific command that notifies the Docker program that a task needs to be completed
  • run – used when we want to create an instance of an image which will be referred to as a container
  • hello-world – the image used to create the container

docker images is used to view a list of images that have been pulled.

The output tells us that there are two images on the system – nginx and hello-world. Each has the following attributes included in the output:

  • TAG – used to logically tag the images
  • IMAGE ID – uniquely identifies the image
  • CREATED – number of days since the image was created
  • SIZE – the virtual size of the image

docker pull is used to “pull” an image or repository from a registry. For example if we want to pull ubuntu 16.04 we would type docker pull ubuntu:16.04.

Most of the images that we will use will be created on top of a base image from the Docker Hub registry. Docker Hub has a library of pre-built images that we can pull to eliminate the need to define and configure our own.

The screenshot for docker pull includes four files that were pulled. These are Docker layer images. Each layer represents an intermediate image. When we make a change to a Dockerfile, Docker only builds on the layer that was changed and the ones that follow. This is called layer caching. We will examine this further in another post.

We will finish this post with a brief demonstration of how we interact with Docker images. Let’s begin by running the docker images command again to view our current images. The output will include our Ubuntu image.

We see that the ubuntu image was tagged with the version (16.04). A tag has no value for the image but is like a marker on a wire made with a label maker for our reference. We could use the tag for version number or for the person who created it.

At this point you should have a better understanding of what a Docker image is. We will go into further detail in future posts but for now we have seen what an image is, that they are comprised of layers, and how to pull one.

We recommend Docker Quick Start Guide by Earl Waud (https://amzn.to/2PklgQy) as a supplemental resource for this blog series. You do not need to purchase this book in order to “credit” our account. Any purchases that you search or make from anywhere in Amazon after clicking on the provided link, will credit this blog and support the continued growth of the library. We are truly grateful for each of our readers and appreciative of those who will help us. There is no cost to you for using our links and they provide an easy way for you to support us.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.