“You donโ€™t truly understand Docker until you stop thinking in commands and start thinking in layers.”

Welcome to the ultimate deep-dive into Dockerโ€™s internal architecture โ€“ beyond the typical “10 must-know commands” and into what really makes Docker containers tick. If you’ve ever wondered “Where does my data go?”, “Why are my changes gone after a restart?” or “Isnโ€™t a container just an image?”, you’re in the right place.

This post explains Docker conceptually, visually and practically โ€“ drawing parallels to traditional OS installation and imaging to make things crystal clear ๐Ÿ’ก.


๐ŸงŠ What Is a Docker Image, Really?

A Docker image is your starting point. It’s:

  • ๐Ÿ“ฆ A collection of read-only layers
  • ๐Ÿงฑ Built via Dockerfile instructions (FROM, RUN, COPY, etc.)
  • ๐Ÿงฌ Immutable and reusable โ€“ you can run it thousands of times

Think of a Docker image like a Windows ISO or a Linux distro installer. It’s a frozen, clean, unbooted system state.

๐Ÿ” You can copy, distribute, and reuse this image without worrying about what happens during runtime. It never changes โ€“ thatโ€™s the point.


โš™๏ธ So What Makes a Container?

When you run a container, Docker does more than just unpack the image.

It adds a few critical components on top:

Component What it does
๐Ÿงฑ Image Layers Base filesystem, read-only
โœ๏ธ Writable Container Layer Stores runtime changes (files, logs, installs)
๐Ÿง  Runtime Metadata Namespaces, cgroups, container ID
๐ŸŒ Networking Context IP, ports, bridges, DNS
๐Ÿงฉ Environment & Entrypoint Startup configs & variables

So, a container = image + writeable layer + runtime context.

Without that writable layer and runtime scaffolding, youโ€™re not running a container โ€” youโ€™re just holding an image.


๐Ÿ“ Writable Layer: Your Temporary Workbench

Every running container gets its own writable layer:

  • ๐Ÿ› ๏ธ Anything you change in the filesystem (install a package, create a file) lives here
  • ๐Ÿ”„ It’s unique per container
  • ๐Ÿงฝ Itโ€™s ephemeral โ€” deleted if the container is removed (unless committed or externalized)

๐Ÿ’ก Analogy: It’s like booting a Live Linux distro and saving files in memory. They exist… until reboot.


๐Ÿงช What Goes Into the Writable Layer?

โœ… File changes
โœ… Software installations
โœ… Edited config files
โœ… Application logs
โœ… Cached data and temp files

โŒ Does not touch the original image. The base layers stay unchanged. That’s the beauty of Dockerโ€™s copy-on-write model.


๐Ÿ’พ Where Do You Put Persistent Data?

Since the writable layer is volatile, Docker gives you two ways to store data outside the container:

๐Ÿ“‚ 1. Volumes

  • Managed by Docker
  • Exists independently of containers
  • Ideal for databases, app storage
docker run -v myvolume:/data myimage

๐Ÿ—‚๏ธ 2. Bind Mounts

  • Mount a specific folder from the host
  • Transparent and flexible, but less portable
docker run -v /host/folder:/app/data myimage

๐Ÿง  Best practice: always externalize any data you want to survive container deletion.


๐Ÿงช Experiment: What If a Container Had No Writable Layer?

Imagine starting a container without:

  • A writable layer
  • A process context
  • Any networking

โ„๏ธ It would be frozen. Unusable. Just the image.

โœ… The moment Docker runs an image, it adds context: processes, memory, IP stack, a filesystem you can write to โ€” and thatโ€™s what we call a container.


๐Ÿ—๏ธ Is Configuration Permanent?

There are two types of configuration:

๐Ÿ”„ Temporary (per container)

Set via docker run or docker-compose:

  • --env, --name, -p, --mount, etc.
  • Stored in the containerโ€™s metadata
  • โ— Gone if the container is deleted

๐Ÿงฑ Permanent (baked into image)

Set via Dockerfile:

  • ENV, EXPOSE, VOLUME, ENTRYPOINT
  • Becomes part of every container based on that image

๐Ÿงช Want to freeze a modified container?

docker commit mycontainer alex/image:configured

That makes a new image including your changes and configuration.


๐Ÿ’ก Docker vs Traditional Imaging (Why Youโ€™re Not Wrong)

This all sounds familiar, doesnโ€™t it?
Thatโ€™s because Docker is basically:

๐Ÿ–ฅ๏ธ Operating system imaging 2.0 โ€” just faster, cleaner, modular and containerized.

Traditional Imaging Docker
Windows ISO / Ghost image Docker Image
OS installation docker run
System changes Writable Container Layer
Capture custom system docker commit or docker build
Restore / Deploy docker run myimage

So yes โ€“ your intuition is spot-on. Docker modernizes the old “install โ†’ customize โ†’ capture” cycle into something far more powerful and portable.


๐Ÿ“Œ Key Takeaways

โœ” A Docker image is a read-only blueprint
โœ” A container is a live instance with its own writable layer
โœ” Runtime info (processes, IPs, mounts) only exists while the container is running
โœ” Containers are ephemeral โ€“ make data persistent via volumes or bind mounts
โœ” If you want changes to persist across runs, build a new image


๐ŸŽฏ Final Words

You now understand Docker better than many whoโ€™ve been using it for years. Why? Because you see how it works under the hood, not just which buttons to press.

If you take away one thing, let it be this:

A Docker container is more than just a running image.
Itโ€™s a composite of filesystem layers, runtime metadata, and process isolation โ€“ built to be reproducible, disposable, and efficient.

๐Ÿ”ฅ Use that knowledge. Structure your containers wisely. And donโ€™t be afraid to build your own images โ€” itโ€™s how Docker is meant to shine.


โœ๏ธ Written by: OpenAi
๐Ÿ“ Topics: Docker Internals, Images vs Containers, Container Architecture, Data Persistence