liveBook · Manning

Chapter 2: Command line

What you will learn in chapter 2 of Podman in Action: Secure, rootless containers for Kubernetes, microservices, and more

The chapter introduces a web-application workflow for learning Podman’s command line, from running and modifying a container to creating and distributing an image.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The chapter introduces a web-application workflow for learning Podman’s command line, from running and modifying a container to creating and distributing an image.

Key terms: container, image, registry, automated, Podman 4.1, registry.access.redhat.com/ubi8/httpd-24, Universal Base Images (UBI), mount container images, different transports

2.1 Working with containers

Introduces working with containers by using podman run to pull and explore a base image before building a containerized application.

Key terms: container registries, podman run, base image, registry.access.redhat.com/ubi8/httpd-24, container storage

2.1.1 Exploring containers

This section walks through an interactive Podman run command and uses the resulting shell to compare a container’s environment with its host.

Key terms: podman run, -ti, --rm, foreground, registry.access.redhat.com/ubi8/httpd-24, layers, blobs, local container storage, default command, /etc/os-release

2.1.2 Running the containerized application

This section shows how to run a web-service container in the background, make it reachable from the host, and prepare or run additional containers.

Key terms: podman run, -d, --detach, -ti, --rm, --tty, -p, --publish, network namespace, host port

2.1.3 Stopping containers

This section shows how to stop running containers, what Podman does when stopping them, and how to change the signal, timeout, or containers selected.

Key terms: podman stop, stop signal, SIGTERM, PID 1, SIGKILL, --timeout, -t 0, --latest, --all, --stop-signal

2.1.4 Starting containers

This section shows how to restart stopped containers with podman start and introduces options for starting multiple containers or connecting a terminal.

Key terms: podman start, container ID, stopped containers, --all, --attach, --interactive, -i

2.1.5 Listing containers

This section shows how to list running or previously created containers with `podman ps` and choose what its output includes.

Key terms: podman ps, --all, running containers, --quiet, --size, container IDs, man podman-ps

2.1.6 Inspecting containers

This section shows how to examine a container’s detailed configuration with podman inspect and find specific information in its output.

Key terms: podman inspect, podman container inspect, podman ps, JSON, less, grep, --format, stop signal, --latest, -l

2.1.7 Removing containers

This section explains when and how to remove containers with `podman rm`, including options for removing all containers or forcing removal.

Key terms: podman rm, container name, --all, --force, man podman-rm

2.1.8 exec-ing into a container

This section shows how to run a command inside an existing container, change its web page, and observe that the change survives a restart.

Key terms: podman exec, --interactive, -i, --tty, podman run, /var/www/html/index.html, Hello World, commit

2.1.9 Creating an image from a container

Shows how to save a configured container as a reusable OCI image with podman commit, while noting that scripted builds are the usual approach.

Key terms: podman commit, OCI image, podman start, --pause, --change, CMD, ENV, Containerfile, Dockerfile, podman build

2.2 Working with container images

This introduction moves from basic container operations to working with images, distinguishing them from containers, and sharing them through registries.

Key terms: container images, containers, container registries

2.2.1 Differences between a container and an image

Distinguishes containers from images, explains how committing a container creates a shareable layered image, and introduces commands for examining image layers and changes.

Key terms: container, image, committed container, storage container, commit, image storage, layers, TAR diffs, uncommitted layer, myimage

2.2.2 Listing images

This section shows how to list locally stored images with Podman, reveal dangling images, and watch image storage use.

Key terms: podman images, local storage, --all, dangling images, <none><none>, man podman-system-prune

2.2.3 Inspecting images

This section shows how to inspect an image’s configuration, extract specific fields, and interpret an unspecified stop signal.

Key terms: podman image inspect, podman inspect, podman image diff, podman image tree, OCI Image Format, --format, STOPSIGNAL, stop signal, default command

2.2.4 Pushing images

This section explains how Podman pushes an image from local storage to another image store, especially a registry, and how to specify and authorize the destination.

Key terms: podman push, image layers, containers/storage, transport, containers/image, destination, transport:ImageName, docker transport, docker://, localhost/myimage

2.2.5 podman login: Logging into a container registry

This section shows how to authenticate to container registries with Podman and manage the credentials it stores.

Key terms: podman login, container registry, credentials, auth.json, /run/user/$UID/containers/auth.json, Base64, --auth-file, REGISTRY_AUTH_FILE, podman logout, --all

2.2.6 Tagging images

This section shows how to give a local image registry-ready and versioned names, push those names, and avoid treating the latest tag as a guarantee of recency.

Key terms: podman tag, localhost registry, image ID, podman images, quay.io/rhatdan/myimage, podman login, podman push, 1.0, latest, version

2.2.7 Removing images

This section shows how to reclaim local image storage with podman rmi and podman image prune, and explains when removing a tag does or does not remove image content.

Key terms: podman rmi, tag, image ID, short name, latest, --force, podman image prune, dangling images, --all, podman system df

2.2.8 Pulling images

This section explains how Podman pulls images into local storage, resolves short image names across registries, and helps avoid pulling from the wrong source.

Key terms: podman pull, container registry, local container storage, podman images, short names, fully specified image name, registry, repository, tag, latest

2.2.9 Searching for images

This section shows how to find container images in a registry with podman search and how to adjust the displayed results.

Key terms: podman search, container registries, httpd, registry.access.redhat.com, --no-trunc, --format

2.2.10 Mounting images

This section shows how to inspect an image’s files without running a container, including the extra namespace step required in rootless mode.

Key terms: podman image mount, root filesystem, read-only mode, rootless mode, podman unshare, user namespace, mount namespace

2.3 Building images

This section introduces image building, explains why developers must maintain image contents, and identifies how Podman builds images from a Containerfile or Dockerfile.

Key terms: container image, building, security updates, podman build, Buildah, Containerfile, Dockerfile, -f

2.3.1 Format of a Containerfile or Dockerfile

This section explains how Containerfile directives build an image’s filesystem, specify how to run it, and produce a stored image with podman build.

Key terms: FROM, base image, scratch, rootfs, copy-on-write filesystem, COPY, RUN, podman build, OCI Runtime Specification, CMD

2.3.2 Automating the building of our application

This section builds an application image from a context directory, then explains how to rebuild it safely and manage the old image.

Key terms: context directory, Containerfile, FROM, COPY, podman build, --tag, CI/CD, cron job, test scripts, podman push

2.4 Summary

This summary recaps Podman’s container, image, and build commands and its compatibility with the Docker CLI.

Where this is used later

Concepts explained in this chapter

← Chapter 1: Podman: A next-generation container engine Chapter 3: Volumes →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.