DEV Community

WebDev
WebDev

Posted on

Docker image layer

Firstly, we need to understand about the docker image.

What is a Docker image?
A Docker image is a file used to execute code in a Docker container. Docker images act as a set of instructions to build a Docker container, like a template. Docker images also act as the starting point when using Docker. An image is comparable to a snapshot in virtual machine (VM) environments.
Docker is used to create, run and deploy applications in containers. A Docker image contains application code, libraries, tools, dependencies and other files needed to make an application run. When a user runs an image, it can become one or many instances of a container.

What is Docker image layer?
Docker images have multiple layers, each one originates from the previous layer but is different from it. The layers speed up Docker builds while increasing reusability and decreasing disk use. Image layers are also read-only files. Once a container is created, a writable layer is added on top of the unchangeable images, allowing a user to make changes.
If you have a tagged image pointing to a chain of 5 images built on each other, that tagged image has 5 layers, or 5 (or 4? depending on how you see it) intermediate images if you prefer that notion.
The following instructions create a layer: RUN, COPY, ADD.
The other instructions will create intermediate layers and do not influence the size of your image.

Top comments (0)