# devops / docker / core-concepts
Demystifying Images & Containers
To master Docker, you must understand its two fundamental building blocks: the static blueprints that define your application, and the dynamic, running environments they spawn.
π¦ Docker Images
A Docker image is like a blueprint. It contains absolutely everything needed to run an application without relying on the host system's configuration.
Read-Only & Layered
Images are completely read-only and built in stacked layers. This layered approach makes them fast to pull, incredibly efficient to store, and highly cacheable.
What's Inside?
An image packs OS libraries (like Debian/Alpine), your specific runtime (Java, Python, PHP), your application code, and your environment configurations.
Think of an image like a cake recipe π°. You donβt eat the recipe β you use it to bake the cake.
π Docker Containers
Container Lifecycle
- start
Spawns the container, attaching a read-write layer over the image.
- stop
Gracefully halts the running processes inside the container.
- restart
Stops and immediately starts the container back up.
- delete
Destroys the container and its temporary read-write data layer.
A container is a running instance of an image. When you start an image, Docker creates a container and adds a writable layer on top, bringing the application to life.
Imagine a mobile app installer. The installer file is the Docker Image. The installed and actively running app on your phone is the Docker Container. You can install the same app many times (multiple containers) from one file.
Essential CLI Operations
Understanding the difference between create, start, and run is crucial. run is simply a combination of create (making the container) followed immediately by start (executing it).
The Key Differences
| Attribute | Docker Image π¦ | Docker Container π |
|---|---|---|
| State | Static, read-only | Running, read-write layer added |
| Purpose | Blueprint / Template | Active Execution Environment |
| Real-Life Analogy | Cake Recipe / App Installer File | Baked Cake / Installed App running |
| Relationship | You need 1 Image... | ...to spin up N Containers |