- Beginner
- Containers and images
How it works
docker run takes an image, adds a thin writable layer on top, creates namespaces (what the process can see) and cgroups (what it may use), then starts the image's command inside. Every container shares the server's kernel: that is why a container is much lighter than a virtual machine, and why a Linux image needs a Linux kernel.
What breaks
A container is not a small server you log into and patch. Anything changed by hand inside it disappears when it is recreated, and nothing outside can reach it until a port is published. Treat containers as disposable: rebuild the image and replace the container.
In a terminal
docker run -d --name web -p 8080:80 nginx:1.27
docker ps
curl http://localhost:8080
See it break, then fix it
Write the Dockerfile or the compose file, type the docker commands, and watch a simulated server run them through reboots, upgrades and traffic. Free to start.