Printing and PDF export are disabled for this content. View it online at Full Stack Learning Simplified.
Docker Images and Containersπ± Beginner
The two core objects: you pull images from a registry and run them as containers. One image is a template; a container is a live, isolated instance of it.
Pull and run
bash
docker pull nginx # download the image
docker run -d --name web -p 8080:80 nginx # run as a background container
docker ps # list running containers-d runs it detached (in the background), --name gives it a friendly name, and -p publishes a port. docker ps -a also shows stopped containers.
Image vs container
| Image | Container | |
|---|---|---|
| Is | a read-only template | a running instance |
| Analogy | a class / blueprint | an object / running process |
| Count | one image | β many containers |
| State | immutable | has a writable layer, can change |
The container lifecycle
bash
docker run nginx # create + start
docker stop web # stop (still exists)
docker start web # start it again
docker rm web # remove it permanentlyA stopped container still exists (and keeps its writable layer) until you rm it. Restarting resumes from where it was.
Layers
Images are built from stacked, cached layers. Multiple images sharing a base layer store it once, and pulling only downloads layers you don't already have β saving space and time.
Warning: Anything a container writes to its own filesystem is lost when it's removed. For data that must survive (databases, uploads), use a volume (its own chapter) β don't store important data inside the container.
Tip: Think of containers as disposable: destroy and recreate them freely from the image. This βcattle, not petsβ mindset is central to Docker β keep state in volumes and configuration in environment variables, not baked into a running container.
Docker Container Takeaway: Volumes persist data outside the container filesystem lifecycle, preventing data loss when container instances restart.
Free preview. Sign in and subscribe to unlock all 982 lessons across 31 courses.
Free preview Β· Β© 2026 Full Stack Learning Simplified