Containers are everywhere in software delivery, and most explanations start with a whale logo and a list of benefits. This series starts with the machine. By the end of this first part you will be able to say what a container is in one sentence, how it differs from a virtual machine, and which programs are involved when you type docker run. If you take the optional lab, you will also install Docker Engine and the Compose plugin on Linux and find one running container from both sides: from inside, where it looks like a tiny computer, and from the host, where it is one more process. No earlier experience with Docker is needed. You should be comfortable typing commands in a Linux terminal.
Time and setup
- Reading: about 12 minutes.
- Optional lab: about 20 minutes, most of it the install.
- Optional advanced step: about 10 minutes.
The lab needs a Linux machine or virtual machine where you can use sudo, and an internet connection to download packages and images. We ran it on Ubuntu 24.04. Docker’s Ubuntu install page also lists Ubuntu 22.04, 26.04 and 26.10.
On macOS or Windows, Docker runs Linux containers inside a small Linux virtual machine that Docker Desktop manages for you (Docker docs). The docker commands in this series work there too, but the advanced step reads Linux files under /proc on the host and works only on Linux. Check the Docker Desktop licence first: it is free for personal use, education, non-commercial open source and small businesses (fewer than 250 employees and less than $10 million in annual revenue), and needs a paid subscription for professional use in larger organizations and for government entities.
Versions this series uses. Every lab in this series ran on Docker Engine 29.10.1, released on 24 November 2026 according to the Engine 29 release notes, with containerd 2.4.2 and runc 1.5.3 as docker version reported them on our machine, and the Docker Compose plugin v5.8.1. The command is docker compose, with a space. Docker’s Compose history page says Compose v5 is functionally identical to Compose v2 and uses the same docker compose command. The old Python tool docker-compose, with a hyphen, is Compose v1; the same page lists only v2 and v5 as supported today.
What you will build
Nothing permanent yet. You will install Docker, run the hello-world test image, start one small Alpine Linux container that sleeps, and inspect it from the inside and from the host. Then you will delete it.
A container is a process with its own view
Docker’s own guide puts it plainly: “A container is an ordinary process on your computer, such as a Node.js server, that runs in isolation” (What is a container?). The guide lists what that isolated process gets:
- Its own filesystem. It sees only the files it was started with, usually a small operating system’s files plus your app and its libraries.
- Its own view of the system. Its own processes, network interfaces and hostname.
- Limits you can set. You can cap its memory and CPU.
On Linux, the kernel provides those three things with two features. A namespace wraps a global resource in an abstraction that “makes it appear to the processes within the namespace that they have their own isolated instance of the global resource” (namespaces(7)). There is one namespace type per resource: a PID namespace for process numbers, a mount namespace for the filesystem view, a UTS namespace for the hostname, a network namespace for interfaces and ports, and a few more. Control groups, or cgroups, organize processes into groups whose use of resources such as memory and CPU “can then be limited and monitored” (cgroups(7)).
The diagram uses the container’s numbers from our lab; the host’s other processes are typical examples. The host saw the container as process 22381, running sleep 600. Inside the container, the same process was PID 1, the hostname was the container’s short ID, and the files were Alpine Linux, although the host runs Ubuntu. uname -r printed the same kernel version on both sides, because there is only one kernel.
Containers and virtual machines
A virtual machine pretends to be a whole computer: it boots a guest operating system with its own kernel. A container does not. It is one process on the host, so every container on that machine shares the host’s kernel. That is why a container starts in about a second and why one machine can run many of them (Docker docs).
The same page names the trade-off. A VM keeps a harder wall between workloads, because the hypervisor draws a hardware boundary between guests. Containers only have what the shared kernel can keep apart. In practice you use both. Cloud servers are usually VMs that run many containers each, and Docker Desktop on macOS and Windows runs your Linux containers inside a small Linux VM, because Linux containers need a Linux kernel to share.
Images, containers and the engine
Four words come up in every lesson:
- An image is the package a container starts from: operating system files, a language runtime, your app and its dependencies, plus settings such as which command to run. Docker’s guide calls images immutable: once built, an image never changes.
- A container is a running (or stopped) instance of an image. You can start many containers from one image.
- Docker Engine is the server side. Its daemon,
dockerd, stores images, containers, networks and volumes, and does the work. - The
dockercommand is a client. It sends your request todockerdover a Unix socket,/var/run/docker.sock, and prints the answer.
Under dockerd there are two more programs. Docker’s install page says “Docker Engine depends on containerd and runc” and installs them together as the containerd.io package (install guide). containerd manages images and containers on the host. runc is the low-level tool that asks the kernel for the namespaces and cgroup and starts your process. Docker donated runc to the Open Container Initiative, which maintains open specifications for container images and runtimes.
Optional lab: install Docker and look inside a container
This lab is optional. The rest of this part, and part 2’s reading, make sense without it. Every command ran on our Ubuntu 24.04 machine on 30 November 2026. IDs, process numbers and times will differ on yours.
Safety: this lab installs system packages and offers root-equivalent access. Step 1 removes conflicting Docker packages your distribution may have installed and adds Docker’s apt repository. Step 4 is optional and adds your user to the
dockergroup. Docker’s docs warn that “the docker group grants root-level privileges to the user” (post-install steps). Do this only on a machine you control, such as a personal laptop or a lab VM. If your distribution’sdocker.io,containerdorruncpackages are installed, step 1 removes them, and their daemon and any containers it runs stop; the data in/var/lib/docker/stays. If none of them is installed, nothing else on the machine stops. To remove Docker Engine later, follow the Uninstall section of the install page. To undo step 4, runsudo gpasswd -d $USER dockerand log in again. If you skip step 4, putsudoin front of everydockercommand in this series. Docker also warns that ports published by containers bypassufwandfirewalldrules; this part publishes no ports, and part 3 binds them to127.0.0.1only.
1. Remove conflicting packages and add Docker’s repository. These lines come from the official Ubuntu instructions. The first one removes unofficial packages such as docker.io that conflict with Docker’s own. apt may report that none of them are installed, which is fine. Images and containers stored in /var/lib/docker/ are not removed by it.
sudo apt remove $(dpkg --get-selections docker.io docker-compose docker-compose-v2 docker-doc docker-buildx podman-docker containerd runc | cut -f1)Explain this command
sudo apt remove $(dpkg --get-selections docker.io docker-compose docker-compose-v2 docker-doc docker-buildx podman-docker containerd runc | cut -f1)sudoRuns the next command with superuser privileges. Removing packages needs that.aptUbuntu's package manager.removeRemoves the packages that follow. Their configuration files stay on disk.$(Shell command substitution. The shell runs the command inside and pastes its output here, so apt receives a list of package names.dpkg --get-selectionsPrints each named package that dpkg knows about, followed by a tab and its state. For a name it does not know, it prints a warning instead.docker.io docker-compose docker-compose-v2 docker-doc docker-buildx podman-docker containerd runcThe unofficial or separately packaged names Docker's install page says to remove, because they conflict with Docker's own packages.|Shell. Sends the previous command's output to the next command.cut -f1Keeps only the first tab-separated field of each line, which is the package name.
Then add Docker’s signing key and apt source:
sudo apt update
sudo apt install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF
sudo apt updateExplain this command
sudo apt update
sudo apt install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF
sudo apt updatesudo apt updateRefreshes apt's list of available packages.sudo apt install ca-certificates curlInstalls the certificate store and curl, which the next lines use to download Docker's signing key over HTTPS.sudo install -m 0755 -d /etc/apt/keyringsCreates the folder /etc/apt/keyrings with mode 0755. -d means create a directory, -m sets its permissions.sudo curl -fsSLDownloads with curl. -f fails on an HTTP error, -s hides the progress bar, -S still shows errors, -L follows redirects.https://download.docker.com/linux/ubuntu/gpgDocker's public signing key for its Ubuntu packages.-o /etc/apt/keyrings/docker.ascWrites the key to this file.sudo chmod a+r /etc/apt/keyrings/docker.ascLets every user read the key file, so apt can read it.sudo tee /etc/apt/sources.list.d/docker.sourcestee writes its input to the named file, here as root. The input is the block up to EOF.<<EOFShell. A here-document: the lines up to the line EOF become tee's input. The shell still expands $( … ) inside it.Types: debThe apt source holds binary packages.URIs: https://download.docker.com/linux/ubuntuDocker's apt repository for Ubuntu.Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")Reads /etc/os-release and prints your Ubuntu codename, such as noble for 24.04, so apt picks the matching packages.Components: stableThe stable channel of Docker's repository.Architectures: $(dpkg --print-architecture)Your machine's architecture as dpkg names it, such as amd64 or arm64.Signed-By: /etc/apt/keyrings/docker.ascapt accepts packages from this source only if they are signed with this key.EOFEnds the here-document.sudo apt updateRefreshes the package list again, now including Docker's repository.
2. Install Docker Engine, the CLI, containerd, Buildx and Compose.
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-pluginExplain this command
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-pluginsudo apt installInstalls packages with apt, as root.docker-ceDocker Engine, the daemon dockerd. ce stands for Community Edition.docker-ce-cliThe docker command-line client.containerd.ioDocker's bundle of containerd and runc, which the install page says Docker Engine depends on.docker-buildx-pluginBuildx, the build plugin behind docker build.docker-compose-pluginCompose v2 and later, used as docker compose.
This installs the newest version in the repository. To match this series exactly on Ubuntu 24.04, the install page shows how to pin a version instead: apt list --all-versions docker-ce lists them, and 5:29.10.1-1~ubuntu.24.04~noble is the version string for Engine 29.10.1. The page also says to check that the service is running with sudo systemctl status docker, and to start it with sudo systemctl start docker if it is not.
3. Check the versions and run the test image.
sudo docker version --format 'Client {{.Client.Version}} / Server {{.Server.Version}}'
sudo docker compose version
sudo docker run hello-worldExplain this command
sudo docker version --format 'Client {{.Client.Version}} / Server {{.Server.Version}}'
sudo docker compose version
sudo docker run hello-worldsudo docker versionShows the version of the docker client and of the daemon it talks to.--format 'Client {{.Client.Version}} / Server {{.Server.Version}}'A Go template that prints only the two version numbers instead of the full report.sudo docker compose versionPrints the Compose plugin's version.sudo docker run hello-worldCreates and starts a container from the hello-world image, pulling the image first if it is missing. The container prints a message and exits.
Client 29.10.1 / Server 29.10.1
Docker Compose version v5.8.1
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
...
The four numbered steps in that message are the diagram above: the client asked the daemon, the daemon pulled an image and created a container, and the container’s output came back to your terminal. Client and Server are two programs, and either can be upgraded separately; both should be the same release.
4. Optional: run docker without sudo. Read the safety banner first. These are the post-install steps. On Ubuntu the package already created the docker group, so you only add yourself to it:
sudo usermod -aG docker $USER
newgrp docker
docker run hello-worldExplain this command
sudo usermod -aG docker $USER
newgrp docker
docker run hello-worldsudo usermod -aG docker $USERAdds your user to the docker group. -a appends, so you keep your other groups. -G names the group. $USER is your user name.newgrp dockerStarts a new shell whose group is docker, so this terminal can use the socket now. Other sessions need a fresh login.docker run hello-worldThe same test as before, now without sudo. If it works, the group change worked.
newgrp docker starts a shell with the new group for this terminal only. Log out and back in to apply it everywhere. The rest of this series writes docker without sudo.
5. Start a container that just sleeps. alpine:3.24 is a very small Linux image. The container runs one command, sleep 600, in the background:
docker run -d --name sleeper alpine:3.24 sleep 600
docker psExplain this command
docker run -d --name sleeper alpine:3.24 sleep 600
docker psdocker runCreate and run a new container from an image.-dDetached. Run the container in the background and print its ID.--name sleeperGives the container a name you can use instead of its ID. Names must be unique.alpine:3.24The image, repository alpine at tag 3.24. Docker pulls it from Docker Hub if it is not on your machine.sleep 600The command the container runs: wait 600 seconds. The container stops when this command ends.docker psList running containers.
e5463b99575d4fcc20c158ed46c71db8e5f15bb164d5ad9ff8c8ed8ea5db6f54
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e5463b99575d alpine:3.24 "sleep 600" Less than a second ago Up Less than a second sleeper
The long line is the container’s full ID. docker ps shows the first 12 characters, and you can use either the ID or the name in later commands. If the image was not on your machine yet, Docker first prints Unable to find image 'alpine:3.24' locally, pulls it, and ends the pull with Status: Downloaded newer image for alpine:3.24.
6. Look from inside. docker exec runs another command inside a running container:
docker exec sleeper ps
docker exec sleeper hostname
docker exec sleeper grep PRETTY_NAME /etc/os-release
grep PRETTY_NAME /etc/os-release
docker exec sleeper uname -r
uname -rExplain this command
docker exec sleeper ps
docker exec sleeper hostname
docker exec sleeper grep PRETTY_NAME /etc/os-release
grep PRETTY_NAME /etc/os-release
docker exec sleeper uname -r
uname -rdocker execExecute a command in a running container.sleeperThe container name from step 5.psLists processes. This is BusyBox ps from inside the Alpine image.hostnamePrints the container's hostname, which Docker sets to the short container ID.grep PRETTY_NAME /etc/os-releasePrints the operating system's name from its os-release file. First inside the container, then on the host.uname -rPrints the kernel release. First inside the container, then on the host.
PID USER TIME COMMAND
1 root 0:00 sleep 600
7 root 0:00 ps
e5463b99575d
PRETTY_NAME="Alpine Linux v3.24"
PRETTY_NAME="Ubuntu 24.04.5 LTS"
6.12.113+
6.12.113+
Inside, sleep 600 is PID 1, and the only other process is the ps you just ran. The hostname is the container ID. The files say Alpine Linux, while the same grep on the host says Ubuntu. The kernel version is the same on both sides, because it is the same kernel. Our lab machine was a cloud VM, which is why its kernel version looks unusual; yours prints your own kernel’s version, and the two lines still match.
7. Look from the host. docker top lists the container’s processes with the host’s process numbers:
docker top sleeper
ps -o pid,user,cmd -p "$(docker inspect --format '{{.State.Pid}}' sleeper)"Explain this command
docker top sleeper
ps -o pid,user,cmd -p "$(docker inspect --format '{{.State.Pid}}' sleeper)"docker topDisplay the running processes of a container, with host process numbers.sleeperThe container name.ps -o pid,user,cmd -pThe host's ps, showing the PID, user and command of one process."$(docker inspect --format '{{.State.Pid}}' sleeper)"Command substitution. docker inspect prints the container's details; the template picks .State.Pid, the host PID of the container's main process.
UID PID PPID C STIME TTY TIME CMD
root 22381 22356 6 11:50 ? 00:00:00 sleep 600
PID USER CMD
22381 root sleep 600
The host’s own ps finds the same process, PID 22381. Nothing about it is hidden from the host; the container’s view is what is limited.
8. Clean up.
docker rm -f sleeper
docker ps -aExplain this command
docker rm -f sleeper
docker ps -adocker rmRemove one or more containers.-fForce. Stops a running container first, then removes it.sleeperThe container name.docker ps -aList all containers, including stopped ones.
sleeper
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7869c26536aa hello-world "/hello" 6 seconds ago Exited (0) 6 seconds ago vibrant_feistel
docker rm -f stops and removes the container in one step. docker ps -a also lists stopped containers. Each hello-world run left one behind, with a name Docker made up, such as vibrant_feistel here. Our capture shows one because the test had run once on that machine just before; if you ran both step 3 and step 4, you see two. Remove each by its name: docker rm vibrant_feistel. The alpine:3.24 and hello-world images stay on disk, so the next container starts without a download.
Optional advanced: namespaces and a cgroup from the host
This step reads Linux kernel files directly, so it works only on a Linux host. It needs a running container, so start the sleeper again first.
Namespaces. Every process has a folder /proc/<pid>/ns/ with one link per namespace type. Two processes share a namespace when their links show the same number. Compare the container’s process with your own shell ($$ is your shell’s PID). Reading another user’s namespace links needs sudo:
docker run -d --name sleeper alpine:3.24 sleep 600
PID=$(docker inspect --format '{{.State.Pid}}' sleeper)
sudo readlink /proc/$PID/ns/pid /proc/$PID/ns/net /proc/$PID/ns/uts /proc/$PID/ns/mnt
readlink /proc/$$/ns/pid /proc/$$/ns/net /proc/$$/ns/uts /proc/$$/ns/mntExplain this command
docker run -d --name sleeper alpine:3.24 sleep 600
PID=$(docker inspect --format '{{.State.Pid}}' sleeper)
sudo readlink /proc/$PID/ns/pid /proc/$PID/ns/net /proc/$PID/ns/uts /proc/$PID/ns/mnt
readlink /proc/$$/ns/pid /proc/$$/ns/net /proc/$$/ns/uts /proc/$$/ns/mntdocker run -d --name sleeper alpine:3.24 sleep 600Starts the sleeper container again in the background, as in step 5.PID=$(docker inspect --format '{{.State.Pid}}' sleeper)Stores the container's host PID in the shell variable PID.sudo readlinkPrints where a symbolic link points. Reading another user's namespace links needs root./proc/$PID/ns/pid /proc/$PID/ns/net /proc/$PID/ns/uts /proc/$PID/ns/mntThe container process's links for its PID, network, UTS (hostname) and mount namespaces. namespaces(7) says processes in the same namespace show the same identifier.readlink /proc/$$/ns/pid /proc/$$/ns/net /proc/$$/ns/uts /proc/$$/ns/mntThe same four links for your own shell. $$ is the shell's own PID. These are your own process, so no sudo.
pid:[4026532204]
net:[4026532206]
uts:[4026532202]
mnt:[4026532201]
pid:[4026532343]
net:[4026531840]
uts:[4026532341]
mnt:[4026532340]
All four numbers differ: the container has its own PID, network, hostname and mount namespaces. Your numbers will be different, and on our lab VM the shell itself ran in namespaces of its own; what matters is that the two sets do not match. These are exactly the four views you saw in step 6.
A cgroup limit. On a cgroup v2 host, a container sees its own memory limit in /sys/fs/cgroup/memory.max. Without a limit it says max. With --memory 64m it is 64 MiB in bytes:
docker exec sleeper cat /sys/fs/cgroup/memory.max
docker run --rm --memory 64m alpine:3.24 cat /sys/fs/cgroup/memory.max
docker rm -f sleeperExplain this command
docker exec sleeper cat /sys/fs/cgroup/memory.max
docker run --rm --memory 64m alpine:3.24 cat /sys/fs/cgroup/memory.max
docker rm -f sleeperdocker exec sleeper cat /sys/fs/cgroup/memory.maxReads the container's cgroup v2 memory limit from inside. max means no limit.docker run --rmRuns a container and removes it as soon as it exits.--memory 64mMemory limit for the container, here 64 MiB.alpine:3.24 cat /sys/fs/cgroup/memory.maxThe image, and the command that prints the limit the container now has.docker rm -f sleeperStops and removes the sleeper container.
max
67108864
sleeper
67108864 is 64 × 1024 × 1024. --rm deletes that second container as soon as its command finishes. docker info --format '{{.CgroupVersion}}' prints 2 on a cgroup v2 host, as ours did.
When it goes wrong
permission denied while trying to connect to the Docker daemon socket. Your user cannot open /var/run/docker.sock. Use sudo, or finish step 4 and open a new login session. id -nG lists your groups; docker must be among them.
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? The client works but dockerd is not running. Check with sudo systemctl status docker and start it with sudo systemctl start docker.
docker-compose: command not found. That is the old v1 command name. Type docker compose, with a space. If that fails too, the docker-compose-plugin package is missing; install it as in step 2.
WARNING: Error loading config file: /home/user/.docker/config.json - stat /home/user/.docker/config.json: permission denied. You ran docker with sudo before joining the group, so ~/.docker is owned by root. The post-install page gives the fix: sudo chown "$USER":"$USER" /home/"$USER"/.docker -R and sudo chmod g+rwx "$HOME/.docker" -R.
Conflict. The container name "/sleeper" is already in use. A container with that name still exists, perhaps stopped. Remove it with docker rm -f sleeper, or pick another name.
apt reports conflicts with containerd or docker.io. A distribution package is still installed. Run the removal line from step 1 again.
Cheat sheet
| Task | Command | Note |
|---|---|---|
| Client and server versions | docker version |
both should be the same release |
| Compose version | docker compose version |
docker compose, with a space |
| Test the install | docker run hello-world |
prints the four steps Docker took |
| Run in the background | docker run -d --name sleeper alpine:3.24 sleep 600 |
prints the full container ID |
| Running containers | docker ps |
add -a for stopped ones too |
| Run a command inside | docker exec sleeper ps |
the container must be running |
| Host view of its processes | docker top sleeper |
host process numbers |
| The host PID | docker inspect --format '{{.State.Pid}}' sleeper |
one more process on the host |
| Memory limit | docker run --memory 64m ... |
seen inside as memory.max |
| Remove when done | --rm on docker run |
deletes the container on exit |
| Stop and remove | docker rm -f sleeper |
-f stops it first |
Recap
- A container is an ordinary process with its own filesystem, its own view of processes, network and hostname, and optional resource limits.
- On Linux, namespaces give the process its view and cgroups limit what it can use. Every container shares the host’s kernel.
- A virtual machine boots a whole operating system with its own kernel. It isolates more strongly and starts more slowly.
dockeris a client;dockerddoes the work, with containerd and runc underneath.- This series uses Docker Engine 29.10.1 and Compose v5.8.1, and always types
docker compose.
Quoted passages in this lesson come from the Docker documentation and from the Linux man-pages project (namespaces(7), cgroups(7)). Docker documentation is licensed under Apache License 2.0. Docker Official Image READMEs and the hello-world image are licensed under the MIT License, © Docker, Inc., where this lesson uses them. Docker® is a registered trademark of Docker, Inc. aitamer.news is not affiliated with or endorsed by Docker, Inc.

The Campfire
CommentsThanks. Your comment is waiting for the desk. Once it is approved it appears here within about a minute.
Add a comment