Card 01/ 05
All 5 cards
ConceptDifficulty: Beginner1 min
What a Container Shares With the Machine
You run your first container and the prompt comes back before you have finished reading the command. A virtual machine asked to do the same job spends a minute booting first.
$ time docker run --rm alpine echo hello
hello
real 0m0.158sNothing booted. A container is an ordinary process on the kernel you are already running, started with its own view of the filesystem, its own process numbers and its own network interface.
| Layer | Where it comes from |
|---|---|
| Kernel | The host's, shared with every other container |
| Filesystem | The image |
| Processes | Its own numbering, starting again at 1 |
| Network | Its own interface, attached to the host |
This is why a container starts in milliseconds and why twenty of them fit on a laptop. There is only ever one kernel running.