An Introduction to Podman: Containers, Rootless Mode, and Host Ports

December 24, 2024

My initial Podman notes covered its relationship to Docker, rootless containers, and graphical management tools. A separate note was titled podman_host_port_rootless.md. These topics fit together: running a container is only the beginning; understanding which user runs it and where its ports are exposed makes the behavior much easier to explain.

Historical note: this article combines podman.md with the topic recorded in podman_host_port_rootless.md, which had no body when consolidated. The front matter uses the earliest creation time and latest modification time of the two files. The port explanation is an expansion of that title, not a reconstruction of a documented incident. Documentation and tool-support details were checked during later consolidation; current support statements are not claims about their availability in 2024.

What Podman does

Podman is an open-source container engine for finding, building, running, and managing containers and images. Its documentation describes it as a:

daemonless, open source, Linux native tool

— Podman contributors, “What is Podman?”1

“Daemonless” means ordinary local container management does not require a central, permanently running engine daemon. Podman can still expose an API service for remote clients and integrations. “Rootless” is a separate property: it means running Podman as an ordinary user rather than as host root. Podman supports both rootless and rootful operation.1

The main objects are:

ObjectPurpose
ImageThe packaged filesystem and configuration used to create containers
ContainerAn instance created from an image, with its own runtime state
VolumeStorage managed separately from a container's writable layer
PodA group of containers that can share resources, such as a network namespace

Podman Desktop is a graphical application for working with containers and Kubernetes workflows. It provides a UI around container tools; it is distinct from the Podman engine.2

How it relates to Docker and Compose

Podman uses OCI container standards and provides a CLI familiar to Docker users.1 Its build command accepts both Containerfile and Dockerfile; the documentation states:

A Containerfile uses the same syntax as a Dockerfile internally.

— Podman contributors, podman build, “Description.”3

For a project that already contains a build file, the basic form is:

podman build -t localhost/my-app:dev .

Compatibility still needs to be checked at the level of the actual workflow. Reusing an image or build file does not establish that every Docker-specific API, networking assumption, or deployment script behaves identically.

Compose has an additional distinction. podman compose invokes an external provider, such as docker-compose or podman-compose. Podman's manual calls it:

a thin wrapper around an external compose provider

— Podman contributors, podman compose, “Description.”4

Consequently, Compose behavior depends on the installed provider as well as Podman. Check the selected provider and project requirements before treating a Compose file as portable without changes.

Rootless changes the host-side permissions

On Linux, rootless Podman uses a user namespace. Container identities are mapped to host identities; appearing as root inside the container does not make the process host root. Rootless setup commonly involves subordinate UID and GID ranges in /etc/subuid and /etc/subgid.5

The practical boundary is explicit in the manual:

Containers running in a user namespace (e.g., rootless containers) cannot have more privileges than the user that launched them.

— Podman contributors, podman run, “--privileged.”6

This is more precise than the original draft's broad claim that rootless operation preserves functionality without compromise. Some workloads require host privileges or access that an ordinary account does not have.

Also, podman ps and sudo podman ps do not simply show the same containers with different permissions. Containers created by a non-root user are not managed by Podman running as root.5 Switching to sudo while debugging can therefore switch the container environment you are inspecting.

On macOS and Windows, Linux containers run through a Linux virtual machine managed with Podman machine. This adds a networking boundary between the desktop OS and the container engine. The Linux host-port explanation below applies directly to native Linux; desktop forwarding also depends on the machine configuration.7

A small example: publish a web server on localhost

With Podman installed and rootless operation configured, this example starts an Nginx container:

podman run -d --name podman-web-demo \
  -p 127.0.0.1:8080:80 \
  docker.io/library/nginx:alpine

The image may be downloaded if it is not present. The tag is convenient for a demonstration; use a deliberate version or digest when reproducing a deployment.

The mapping means:

Browser → 127.0.0.1:8080 on the host → port 80 in the container

8080 is the host port; 80 is the container port. The explicit 127.0.0.1 binding makes this a local-only example. Omitting the host IP binds the published port on all host IPs by default.6

Inspect and try the service:

podman ps
podman port podman-web-demo
podman logs podman-web-demo
curl http://127.0.0.1:8080/

After the demonstration, stop and remove that container:

podman stop podman-web-demo
podman rm podman-web-demo

These commands leave the downloaded image available for reuse.

Why rootless publication of port 80 can fail

Changing the example's mapping to 127.0.0.1:80:80 requires the forwarding process to bind port 80 on the host. On a normally configured Linux host, ordinary users cannot bind ports below 1024 without the relevant privilege.

The Linux kernel setting net.ipv4.ip_unprivileged_port_start defines the first unprivileged port in a network namespace. Its documented default is 1024. Ports below the configured threshold require root or CAP_NET_BIND_SERVICE.8

MappingHost-side requirement
127.0.0.1:8080:80Bind host port 8080; normally above the privileged range
127.0.0.1:80:80Bind host port 80; normally requires additional privilege

This restriction concerns the host-side bind. It does not mean every rootless container application is forbidden from listening on port 80 inside its own network namespace.

Read the threshold on the Linux host with:

sysctl net.ipv4.ip_unprivileged_port_start

For development, using an available high host port is usually sufficient. For a service that needs public port 80 or 443, one design is a reverse proxy authorized to bind those ports, forwarding requests to the rootless service on a high port. Another option is an administrator-approved change to the threshold. That changes which ports ordinary processes can bind in the affected network namespace, so it is a system policy decision rather than a private setting for one container.8

Do not confuse this with --network=host, which shares the host network namespace rather than setting up this port mapping. It does not grant an ordinary user permission to bind a privileged host port.68

Graphical tools from the original notes

The original list contained Podman Desktop, Cockpit, and Portainer. They serve different contexts:

ToolWhere it fits
Podman DesktopA desktop UI for local container development and Kubernetes workflows.2
Cockpit with cockpit-podmanBrowser-based administration of Podman containers on a Linux system.9
PortainerA container-management UI whose documented Podman integration uses Podman's Docker-compatible API.10

Portainer's support conditions matter for a rootless introduction. At consolidation time, its official installation guide assumed rootful Podman and explicitly did not officially support rootless Podman. It should not be presented as an interchangeable rootless frontend.10

The Cockpit link in my original draft was a 2015 article about Cockpit's Docker integration.11 I retain it as historical reading, but the applicable Podman component is cockpit-podman, listed by the Cockpit project itself.9 The old Docker installation instructions are not a current Podman setup guide.

Moving beyond one container

The saved Red Hat lesson, Start the two running containers, demonstrates a Python application and Redis on a named network, viewed through Podman Desktop.12 It is a useful next step after understanding a single published port: application services can communicate on a container network, while selected ports provide access from the host.

A Podman pod is another arrangement. Containers sharing a pod's network namespace can communicate over localhost; they also share its port space. Published ports belong to the pod in that setup.6 A local Podman pod is not, by itself, a Kubernetes cluster. The Red Hat learning path continues into Kubernetes as a separate step.12

For initial use, the most useful distinctions are the engine versus its UI, rootless versus rootful ownership, and the host port versus the application's container port. Those boundaries explain much of the behavior that otherwise looks like inconsistent container tooling.

References

Footnotes

  1. Podman contributors. (n.d.). What is Podman? Podman documentation, opening paragraph. https://docs.podman.io/en/stable/ . Original project link: https://podman.io/ ↩ ↩2 ↩3

  2. Podman Desktop contributors. (n.d.). Podman Desktop: Containers and Kubernetes. “Intuitive Graphical Interface” and “Streamline Kubernetes workflows.” https://podman-desktop.io/ ↩ ↩2

  3. Podman contributors. (n.d.). podman-build (v5.3.2 documentation). “Description,” first paragraph. https://docs.podman.io/en/v5.3.2/markdown/podman-build.1.html ↩

  4. Podman contributors. (n.d.). podman-compose. “Description,” first paragraph. https://docs.podman.io/en/stable/markdown/podman-compose.1.html ↩

  5. Podman contributors. (n.d.). podman (v5.3.2 documentation). “Rootless mode.” https://docs.podman.io/en/v5.3.2/markdown/podman.1.html#rootless-mode ↩ ↩2

  6. Podman contributors. (n.d.). podman-run (v5.3.2 documentation). “--privileged,” final paragraph; “--publish”; “--network.” https://docs.podman.io/en/v5.3.2/markdown/podman-run.1.html ↩ ↩2 ↩3 ↩4

  7. Podman contributors. (n.d.). podman-machine. “Description.” https://docs.podman.io/en/stable/markdown/podman-machine.1.html ↩

  8. Linux kernel contributors. (n.d.). IP sysctl. “IP Variables,” ip_unprivileged_port_start. https://www.kernel.org/doc/html/latest/networking/ip-sysctl.html#ip-variables ↩ ↩2 ↩3

  9. Cockpit Project. (n.d.). Applications. “Podman Containers.” https://cockpit-project.org/applications.html ↩ ↩2

  10. Portainer. (n.d.). Install Portainer CE with Podman on Linux. API compatibility note and environment assumptions; support information checked during later consolidation. https://docs.portainer.io/start/install-ce/server/podman/linux ↩ ↩2

  11. Visakh S. (2015, August 24). Docker management simplified – How to use Cockpit to deploy and manage Docker containers [Blog post]. Bobcares. Historical link from the original draft. https://bobcares.com/blog/docker-management-simplified-how-to-use-cockpit-to-deploy-and-manage-docker-containers/ ↩

  12. Schenck, D. (2023, November 17). Start the two running containers. Red Hat Developer. In Container development using Podman, Podman Desktop, and Kubernetes (learning path published January 25, 2024). https://developers.redhat.com/learning/learn:openshift:develop-containers-using-podman-desktop-and-kubernetes/resource/resources:start-two-running-containers ↩ ↩2

© 2024 borui. All rights reserved. This content may be freely reproduced, displayed, modified, or distributed with proper attribution to borui and a link to the article: borui (2024-12-24). An Introduction to Podman: Containers, Rootless Mode, and Host Ports. https://caiborui.com/blog/2024-12-24-en-introduction-to-podman

@misc{borui2024-2fa13f8a,
  author = {borui},
  title = {{An Introduction to Podman: Containers, Rootless Mode, and Host Ports}},
  year = {2024},
  publisher = {borui's blog},
  url = {https://caiborui.com/blog/2024-12-24-en-introduction-to-podman}
}