Docker fundamentals
Docker packages an app and its whole environment into one image, then runs that image anywhere as an isolated container.
key idea / Docker itselfcontainer / good pathhost / watch outproblem / blockedneutral
Why Docker exists
The classic bug is a program that works on one machine and not another. Docker removes the difference by shipping the environment too.
The four moving parts
You type commands into the CLI; a background daemon does the work.
Image versus container
The image is the blueprint. A container is a running copy of it with a thin writable layer.
Where data survives
Anything written to the container layer disappears with the container, so persistent data belongs in a volume.
Try it yourself
Run these in order. Version numbers on your machine will differ.
-
Step 1 · Client and daemon
docker versionprints two blocks. Client is the command you typed. Server is the daemon. If the Server block is missing, the daemon is not running.$ docker version Client: Version: 27.3.1 Server: Engine: Version: 27.3.1 -
Step 2 · What the daemon is holding
docker infois the daemon’s inventory: how many images and containers it has, and which storage driver it uses.$ docker info --format 'containers={{.Containers}} images={{.Images}} driver={{.Driver}}' containers=0 images=0 driver=overlayfs -
Step 3 · An image is not a container yet
Pull stores an image. Nothing is running until
run.$ docker pull hello-world $ docker images REPOSITORY TAG IMAGE ID SIZE hello-world latest d2c94e258dcb 13.3kB $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES -
Step 4 · The four objects
You just used all four. The registry served
hello-world. The daemon stored the image.docker psis empty because you have not created a container. The next chapter does that.
Recap
- An image is a read-only template. A container is a running instance with one writable layer.
- The
dockerCLI only talks to the daemon (dockerd); the daemon builds, stores and runs. - A registry stores images.
pushuploads,pulldownloads. - Persistent data belongs in a volume, not in the container layer.
Quick check
docker pull hello-world and docker ps shows nothing. Is something wrong?Show answer
No. Pull only stores the image. A container exists only after docker run, and hello-world exits immediately, so docker ps -a would show it.