...
/Docker: Images, Registry, and Repository
Docker: Images, Registry, and Repository
Learn about the Docker registry, Docker repository, and how to work with Docker images.
Docker images
Every Docker container stems from a Docker image. Docker images are the building blocks of everything we do with Docker. All our workflows will be derived from it.
A typical Docker image is composed of multiple layers. These layers are stacked on top of one another, with a one-to-one mapping. They contain everything required to run an application, including application code, application runtime, libraries, environment variables, configuration files, and so on.
Docker combines these layers as a single immutable object known as a Docker image.
The diagram below depicts how the Docker image is made of layers:
This layering approach of Docker images offers several benefits, such as those listed below:
-
Reusability: The layer can be reused for other images.
-
Faster build time: A layer will be downloaded once, which saves build time, especially in CI.
-
Flexibility: We can build a new Docker image by basing it on an existing one.
-
Faster download: We can parallelize the downloading of each layer.
-
Space efficiency: Since multiple images can share layers, space is efficiently used and performance is increased.
Docker images are small and frequently in the megabyte range because they only package what’s required to run an application. For example, the Docker alpine
image is only MB in size.
There are two ways to get Docker images. We can either reuse an existing image or create a new one. In the coming paragraphs, we focus on reusing existing images created by us or someone else.
Docker image registry and image repository
If we’re a developer, we’re probably familiar with package registries. A package registry, such as NPM, PyPI, ...