Compute Virtualization (Containers and Virtual machines)

Hello Gowtham

Welcome back! Immutability, in general, is a word that means “unchangeable” or “unmodifiable”. When we apply it in terms of Docker and other technological concepts (such as blockchain), we are referring to an immutable, unchangeable, read-only entity. If you want to modify it, you can’t. You must create a new one with the new parameters you want. Let’s dig deeper…

A Dockerfile is a blueprint (aka recipe) containing step-by-step instructions to build a container image. It specifies the base OS, packages to install, files to copy, configurations, and commands to run.

A container image is the compiled result of processing that Dockerfile. Once built, this image is immutable. It has that unmodifiable characteristic. This is the way Docker is built, it is a primary rule that cannot and should not be broken. Think of it as a frozen, read-only snapshot of your application at a specific point in time. Finally, a container is a running instance created from that image, with a temporary writable layer for runtime changes.

To change any characteristic of the resulting container, you must return to the blueprint, modify it, build a new image from it, and then deploy the new container. You can keep the old one or get rid of it. In this sense, “modifiability” can only take place at the blueprint, not at the container, and that’s what immutability of the container means.

I hope this has been helpful!

Laz