Skip to main content

Docker Images

Docker Images​

As you saw before in the previous article, Docker will bundle your project into a "Docker Image", But what exactly is a docker image.

A docker image is a single isolated executable software package that has everything needed to run a software, it has:

  1. The code itself

  2. The Runtime environment (EG: Python, .NET etc)

  3. Environmental variables

  4. Libraries (EG: Node modules)

  5. Config files

A docker image serves as a blue print for a docker container (which will be explained more briefly in the next lesson).

IE: A docker container is an instance of a docker image.

Here are some characteristics of a docker image:

  1. Portable: They can easily be transported across devices

  2. Immutable: They cannot be modified once built, if you want to change it, rebuild it with your code again with the modifications

  3. Layered: Images are composed of layers, where each layer represents a set of changes (e.g., adding a file, installing a package). These layers are stacked and shared among images, saving disk space and reducing redundancy.

elaborating on point 3, Docker images are build as so:

But to save space, between images, the layers are shared

Here are the components of a docker image:

  1. Base image: Each docker image runs on an OS inside it, this is typically Ubuntu or alpine, a base image of the OS is part of the component, as seen in the last layer of both the images above

  2. Code: The literal software you want to run

  3. Dependencies: Node modules etc

  4. Instructions: This is the Dockerfile, we'll talk about this in lecture 4. in a nutshell this file contains the instructions to the docker image on how to run the code and the commands to run to install dependencies ETC.

Docker Tags​

These are just Versions of the images with a human-understandable name.

EG: 

When pulling a docker image you can specify what version (tag) you want.