1.1. Images

Docker images

You can search for images available on Docker Hub by clicking the Explore link or by typing mariadb into the search field: https://hub.docker.com/search/?q=mariadb&type=image

You will get a list of results and the first hit will probably be the official image: https://hub.docker.com/_/mariadb

This page contains instructions on how to pull the image. Let’s pull a certain version of mariadb:

docker pull mariadb:12.0

When using images from Docker Hub or other sources, always follow these practices:

  • Is it an official image ? Official Images are a good starting point, please read here why.

  • What is installed in the image?

    • Read the Dockerfile that was used to build the image
    • Check the base image
    • Check the vulnerabilities of this image. Does it affect your application?
    • Check the dependencies of the image.
    • Compare your images Digest to the sha256 value shown on dockerhub.

After an image has been downloaded, you may then run a container using the downloaded image with the sub-command run. If an image has not been downloaded when Docker is executed with the sub-command run, the Docker client will first download the image, then run a container using it:

docker run hello-world:linux

To see the images that have been downloaded to your computer type:

docker images

The output should look similar to the following:

IMAGE                ID             DISK USAGE   CONTENT SIZE   EXTRA
hello-world:latest   f7931603f70e       20.3kB         3.96kB    U   
hello-world:linux    53cc1017c16a       20.3kB         3.96kB    U   
mariadb:12.0         607835cd628b        456MB          105MB  

The hello world container you ran in the previous lab is an example of a container that runs and exits, after emitting a test message. Containers, however, can be much more useful than that, and they can be interactive. After all, they are similar to virtual machines, but they are more resource-friendly.

For example, let’s run a container using the downloaded image of MariaDB. The combination of the -i and -t switches gives you interactive shell access to the container:

docker run -it mariadb:12.0

An error has popped up!

2025-11-15 19:55:00+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:12.0.2+maria~ubu2404 started.
2025-11-15 19:55:00+00:00 [Warn] [Entrypoint]: /sys/fs/cgroup///memory.pressure not writable, functionality unavailable to MariaDB
2025-11-15 19:55:00+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2025-11-15 19:55:00+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:12.0.2+maria~ubu2404 started.
2025-11-15 19:55:00+00:00 [ERROR] [Entrypoint]: Database is uninitialized and password option is not specified
        You need to specify one of MARIADB_ROOT_PASSWORD, MARIADB_ROOT_PASSWORD_HASH, MARIADB_ALLOW_EMPTY_ROOT_PASSWORD and MARIADB_RANDOM_ROOT_PASSWORD
🤔 Why do I get an error? Is this a bug in the image?

Everything is fine, to run this image there is some configuration needed. Read the following excerpt carefully.

error: database is uninitialized and password option is not specified
        You need to specify one of MARIADB_ROOT_PASSWORD, MARIADB_ALLOW_EMPTY_ROOT_PASSWORD and MARIADB_RANDOM_ROOT_PASSWORD

We will add the configuration later.

🤔 What's an image?

Think of an image as a blueprint of what will be in a container when it runs.

  • An image is a collection of files + some metadata (or in technical terms: those files form the root filesystem of a container)
  • Images are made of layers, conceptually stacked on top of each other
  • Each layer can add, change or remove files
  • Images can share layers to optimize disk usage, transfer times, and memory use
  • You build these images using Dockerfiles (in later labs)
  • Images are immutable, you cannot change them after the creation
🤔 What's the difference between a container and an image?

When you run an image, it becomes a container.

  • An image is a read-only filesystem
  • A container is an encapsulated set of processes running in a read-write copy of that filesystem
  • To optimize container boot time, copy-on-write is used instead of regular copy
  • docker run starts a container from a given image