Core fundamentals
Hour overview
This hour gives you the mental model for everything after it. You will learn what runs when you type a Podman command, what a rootless container is, how an image name maps to content, and how to start, watch, stop and remove a container. You finish with a lab that serves a web page from a container and checks it from the host.
Time allocation. Module 0 is pre-class. The six timed modules fill the 60 minutes: architecture 8, images 8, lifecycle 12, logs and inspect 10, Docker compatibility 12, lab 10.
Objectives. By the end of the hour you can:
- explain why Podman has no daemon, and what conmon, the OCI runtime and user namespaces do
- say which image a short name like
nginxresolves to, and why a full name is safer - start a container in the background, list it, stop it, start it again and remove it
- read logs, run a command inside a container and read its state with
inspect - explain which Docker habits carry over and which need a change
Lab. A web service in a container, published on port 8080 and checked with curl. It runs rootless.
Modules
Module 0: environment (before class)
Complete this before the hour. It takes about 15 minutes.
Linux. Install Podman from your distribution. On Ubuntu:
sudo apt-get update
sudo apt-get install -y podman
podman --version
podman info
Ubuntu 24.04 ships Podman 4.9.3. The course is written for Podman 5.x. The commands in hours 1 to 4 do not depend on the difference. Hour 5 explains the networking difference.
Rootless setup. Check that your user has a range of subordinate IDs. Rootless containers need it:
grep "^$USER:" /etc/subuid /etc/subgid
Each file should show one line for your user, for example alice:100000:65536. If a line is missing, ask your administrator to add one, then run podman system migrate.
Windows. Install Podman from the Podman releases page on GitHub. Then create and start the Linux VM that Podman uses:
podman machine init
podman machine start
podman machine list
podman machine list should show the machine as running.
macOS. Install Podman with Homebrew, then start the machine:
brew install podman
podman machine init
podman machine start
Course folder. Copy the podman-app folder from the course site to your machine, and make it your working folder:
cd podman-app
ls
You should see app.py, Containerfile, compose.yaml and .containerignore.
Architecture and rootless
Docker is built around one long-running service, dockerd. The docker command sends requests to it, and the service does the work. Podman has no such service. A podman command starts, does its work and exits. The process that runs a container is a child of a small helper called conmon, which keeps the container's output and records its exit code. Once the container is running, you can close your terminal and the container keeps running.
The steps behind podman run look like this:
you --> podman (CLI, one process per command)
| pulls the image, prepares the root file system
v
conmon (one small monitor process per container)
| starts the container with the OCI runtime (crun or runc)
v
container process
(namespaces for isolation, cgroups for limits)
Rootless means the whole chain runs as an ordinary user. Linux user namespaces map user 0 (root) inside the container to your own user ID outside it. The IDs in between come from the subordinate ranges in /etc/subuid and /etc/subgid. A process that escapes the container lands as your user, not as root on the host. That is a real reduction of risk. It is not a complete boundary, and hour 7 covers its limits.
Why it matters. No daemon means no single process whose failure stops every container. It also means no root-owned socket that a group member can use to gain root. The price is that nothing starts your containers after a reboot. Hour 3 and hour 7 deal with that.
Check your setup:
podman info
Expected: a long report with sections for the host, the store and the registries. Look for the rootless setting and the helper that rootless networking uses. That helper is pasta on Podman 5.x and slirp4netns on Podman 4.x. Hour 5 covers both.
Verify that the CLI itself works:
podman version
Expected: a client section and, on most installs, a server-side section with the same version. On Linux without a daemon, the server section can be missing or minimal. That is normal for Podman.
daemon in an error message, you are probably reading an old Docker example. Podman errors mention conmon, the OCI runtime or the storage layer.Production note. Rootless does not make a container safe by itself. Hour 7 covers the remaining steps: dropped capabilities, read-only root file systems and no privileged mode.
Images and registries
An image is packaged content in layers, plus metadata such as the default command. A registry stores images and serves them by name. A full image name has four parts:
registry / namespace / name : tag
docker.io / library / alpine : 3.20
A short name such as alpine leaves out the registry. Podman resolves it through unqualified-search-registries in registries.conf. In a terminal, Podman can ask which registry to use. In a script, a short name can fail. Use full names in scripts.
A tag like 3.20 is a label that someone can move. A digest like sha256:9f... identifies the exact content. You can pull by tag and check the digest:
podman pull docker.io/library/alpine:3.20
podman images
podman images --digests
Expected: alpine appears with tag 3.20. The --digests column shows a sha256: value. Run the pull again and Podman reuses the local copy, so no layers are downloaded a second time.
Pull by digest when you need an exact image. Copy the digest from podman images --digests and use it in the name:
podman pull docker.io/library/alpine@sha256:<digest-from-the-list>
Verify that two references point to the same content: the image ID shown by podman images is the same for both names.
docker.io/library/nginx or your own registry name in scripts.Production note. Pin production deployments by digest. Use tags for local development, where you want the latest build.
Run, list, stop and remove
podman run creates a container from an image and starts it. If the image is not on disk, Podman pulls it first. The container stays in one of a few states: running (Up), stopped (Exited), or removed.
Start a web server in the background, publish its port and look at it:
podman run -d --name web -p 8080:80 docker.io/library/nginx:alpine
podman ps
-druns the container detached, so your shell returns.--name webgives it a name you can use in later commands.-p 8080:80publishes container port 80 on host port 8080.
Expected: podman ps lists web with the image nginx:alpine and a status that starts with Up. The ports column shows the mapping from host port 8080 to container port 80.
Stop it, check the state and start it again:
podman stop web
podman ps
podman ps -a
podman start web
podman ps
Expected: after stop, podman ps no longer lists web, but podman ps -a does, with status Exited. After start, it is running again. The container keeps its name, its configuration and its writable layer. A stopped container still takes disk space.
Remove it, and run a one-off command that cleans itself up:
podman rm -f web
podman run --rm docker.io/library/alpine:3.20 echo "runs once and is removed"
podman ps -a
Expected: the echo line prints, and podman ps -a does not list a container for it, because --rm removes the container when it exits. rm -f stops a running container before it removes it.
podman rm refuses to remove a running container without -f. Stop it first if you want to keep the rule.Common errors.
address already in useon port 8080: another process listens there. Choose another host port, or find the process withss -ltnp.no such container web: the name is wrong, or the container was removed. Checkpodman ps -a.
Production note. Give every long-running container a name and a restart plan. A nameless container is hard to find during an incident.
Logs, exec and inspect
Three commands answer most questions about a running container: logs shows what the process wrote, exec runs a new process inside it, and inspect shows its configuration and state.
Read the logs and follow them live:
podman run -d --name web -p 8080:80 docker.io/library/nginx:alpine
curl -s http://127.0.0.1:8080/ | head -5
podman logs web
podman logs -f web
Expected: logs shows access lines written by nginx, one per request, including the request you just made with curl. logs -f keeps printing new lines. Press Ctrl+C to stop following. The container keeps running.
Run a command inside it:
podman exec web nginx -v
podman exec -it web sh
Expected: the first command prints the nginx version. The second opens a shell in the container. Type hostname and exit. exec starts a second process in the same container. When you exit, only that process stops.
Read the configuration and state:
podman inspect web
podman inspect --format '{{.State.Status}}' web
podman top web
Expected: inspect prints a long JSON document with the command, environment, mounts, network settings and state. The --format line prints one value, running. top lists the processes inside the container. You should see nginx master and worker processes.
--format with inspect in scripts. The full JSON is for reading, and the templated value is for checks.Common errors.
exec: "bash": executable file not found: the image does not contain bash. Usesh, which Alpine-based images provide.Error: container web is not running:execneeds a running container. Start it, or read its logs withpodman logsto see why it stopped.
Production note. When an incident starts, collect podman logs, podman inspect and podman events before you change anything.
Docker compatibility and podman machine
Most Docker commands work with Podman. The CLI accepts the same subcommands and most flags, and it reads the same image format. Many people use alias docker=podman in their shell. Test that alias in a non-critical script before you rely on it, because differences show up in flags for privileged mode, host mounts and some Compose behaviour.
| Topic | Docker | Podman |
|---|---|---|
| Service behind the CLI | central daemon dockerd | none. Each command does the work |
| Default user | usually root, through the daemon | rootless is supported and common |
| Compose | docker compose | podman compose, which calls an external provider |
| Docker API for tools | the Docker socket | podman system service exposes a Docker-compatible API |
| Start after reboot | restart policy handled by the daemon | Quadlet or systemd (hour 7) |
The Docker API. Some tools insist on the Docker API. Podman can serve it on a socket. For a rootless user the default socket is $XDG_RUNTIME_DIR/podman/podman.sock:
podman system service --time=0 unix://$XDG_RUNTIME_DIR/podman/podman.sock &
export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/podman/podman.sock
Expected: the service keeps running in the background. Tools that read DOCKER_HOST now talk to Podman. Stop the service with kill %1 in the same shell, or with fg and Ctrl+C.
Windows and macOS. Podman runs Linux containers in a VM that you manage with podman machine. On Windows the VM uses WSL 2. Open a shell inside the VM when you need to look at its files or processes:
podman machine ssh
Expected: a shell prompt on the Linux VM. exit returns you to Windows.
--privileged gives a container all Linux capabilities and access to host devices. Many Docker examples use it. Do not copy it into production. Hour 7 shows the alternatives.Common errors.
Cannot connect to Podman: on Windows or macOS, the machine is stopped. Runpodman machine list, thenpodman machine start.- A tool still talks to the Docker daemon: check that
DOCKER_HOSTis set in the same shell where you start the tool.
Production note. Document which Podman commands your team uses and which Docker-only features it depends on. That list tells you what the migration will break.
Lab: your first web service
Goal. Serve a web page from a container, check it from the host, read its logs and clean up.
Steps.
podman pull docker.io/library/nginx:alpine
podman run -d --name lab1 -p 127.0.0.1:8080:80 docker.io/library/nginx:alpine
podman ps
curl -s http://127.0.0.1:8080/ | grep -i "welcome to nginx"
podman logs lab1
podman stop lab1
podman rm lab1
podman ps -a
Expected output.
podman pslistslab1with statusUp.curlprints a line containingWelcome to nginx!.podman logs lab1shows at least one access line for the request.- After
rm,podman ps -ano longer listslab1.
Verify. The result is verified when the curl line matches and podman ps -a no longer lists the container. If curl fails, check podman ps first. If the container is not running, read podman logs lab1 for the reason.
Clean up. The rm step removes the container. The image stays on disk. Remove it with podman rmi docker.io/library/nginx:alpine if you want the space back.
Troubleshooting.
curl: (7) Failed to connect: the port mapping is wrong, or the container is not running. Checkpodman psfor the127.0.0.1:8080->80mapping.connection reset: another process already listens on port 8080. Choose another port, and change the-pvalue to match.
Cheat sheet
| Task | Command |
|---|---|
| Show engine and platform info | podman info |
| Pull an image | podman pull docker.io/library/alpine:3.20 |
| List images with digests | podman images --digests |
| Run detached with a name and a port | podman run -d --name web -p 127.0.0.1:8080:80 IMAGE |
| Run once and remove | podman run --rm IMAGE COMMAND |
| List running containers | podman ps |
| List all containers | podman ps -a |
| Stop, start, remove | podman stop web, podman start web, podman rm web |
| Force remove a running container | podman rm -f web |
| Logs and follow logs | podman logs web, podman logs -f web |
| Run a command inside | podman exec -it web sh |
| Full configuration and state | podman inspect web |
| One field | podman inspect --format '{{.State.Status}}' web |
| Processes inside | podman top web |
| Docker-compatible API | podman system service --time=0 unix://$XDG_RUNTIME_DIR/podman/podman.sock |
| Windows or macOS VM | podman machine init, podman machine start, podman machine ssh |
Capstone lab: a service you can restart
Goal. Run the sample service from podman-app, check it, restart it and prove the container is replaceable.
cd podman-app
podman build -t localhost/podman-app:dev .
podman run -d --name svc -p 127.0.0.1:8000:8000 localhost/podman-app:dev
curl -s http://127.0.0.1:8000/health
podman stop svc
podman start svc
curl -s http://127.0.0.1:8000/health
podman rm -f svc
Expected. Both curl calls print {"status": "ok"}. The build step takes a minute the first time because it pulls the Python base image.
Verify. podman ps lists svc while it runs. podman ps -a lists nothing after rm.
Clean up. podman rmi localhost/podman-app:dev removes the image. You will rebuild it in hour 2.