Key Points

Introduction to Containers


  • Containers package an application with its dependencies into a portable, self-contained unit that runs consistently across different systems.
  • Unlike virtual machines, containers share the host’s Linux kernel, making them lightweight and fast to start.
  • Linux namespaces and cgroups provide the isolation and resource control that containers rely on.
  • Container images are built from read-only layers; a thin writable layer is added at runtime and is lost when the container is removed (although there are options for filesystem persistence).
  • On MacOS and Windows, containers run inside a lightweight Linux virtual machine managed by the container engine.
  • Podman is a daemonless, open source container engine whose commands are largely interchangeable with Docker.

Getting Started


  • podman --version confirms that Podman is installed and accessible from the command line.
  • On MacOS and Windows, Podman requires a lightweight Linux virtual machine, initialised with podman machine init and started with podman machine start.
  • On Linux and Windows Subsystem for Linux (WSL), Podman runs natively and no virtual machine is needed.
  • Podman operates in rootless mode by default, meaning it does not require administrator privileges.

Managing Containers


  • podman container list -a shows all containers including stopped ones whilst podman container list shows only running containers.
  • An exit code of 0 means a container completed successfully, whereas a non-zero exit code indicates an error.
  • podman run always creates a new container, and podman container start restarts an existing stopped container.
  • The -p host-port:container-port/protocol option maps a port inside a container to a port on the host, enabling access to services running in the container.
  • The -d flag runs a container in detached (background) mode.
  • podman logs <name> retrieves its output.
  • podman exec -ti <container> /bin/bash opens an interactive shell inside a running container.
  • The -v <host-dir>:<container-dir> option mounts a host directory into the container, allowing both to access the same files.
  • All containers based on an image must be removed before that image can be deleted.

(Optional) Container Registries


  • podman info displays Podman’s full configuration, including which registries are configured for searching.
  • On macOS and Windows, Docker Hub is configured as a search registry by default; on Linux this typically requires manual configuration.
  • Registry search is configured by editing ~/.config/containers/registries.conf.
  • podman search <term> returns images from all configured registries whose names or descriptions match the search term.