Skip to content
Tutorials Center
My learning

Topics

Lesson 12 of 37 ยท Rootless and Security

Rootless Ports, Networking and Storage Limits

Handle the practical limits of rootless Podman: ports below 1024, the pasta and slirp4netns network helpers, storage drivers, cgroup limits, ping and lingering.

Rootless Podman works well for most jobs, but a regular user is not an administrator, and some things that need privilege behave differently. Knowing these limits in advance turns "mysterious error" into "oh, that again". This lesson covers the five that you will meet: low ports, networking without root, where storage lives, resource limits, and background services after you log out.

None of these are bugs. Each is the kernel refusing something that an unprivileged user should not do. Every one has a clean workaround.

Ports below 1024

On Linux, only root may normally bind TCP and UDP ports below 1024. So a rootless container cannot publish -p 80:80:

Terminal
podman run -d -p 80:80 docker.io/library/nginx:alpine
# Error: rootlessport cannot expose privileged port 80 ...

Your options, from best to most invasive:

  1. Use a high host port such as 8080, and let a reverse proxy or a firewall rule bring port 80 to it. For development this is almost always enough.
  2. Lower the kernel's threshold for the whole machine. This is an administrator's decision, because it allows every user to bind those ports:
Terminal
sudo sysctl net.ipv4.ip_unprivileged_port_start=80
echo 'net.ipv4.ip_unprivileged_port_start=80' | sudo tee /etc/sysctl.d/99-unprivileged-ports.conf
  1. Redirect port 80 to 8080 with the firewall, so the container keeps a high port:
Terminal
sudo firewall-cmd --add-forward-port=port=80:proto=tcp:toport=8080 --permanent   # firewalld
  1. Run that single service as rootful, with sudo podman.

Choose the option with the smallest blast radius: usually 1 or 3.

Networking without root

A normal user cannot create network interfaces or edit the firewall of the host. So rootless containers get a user-space network stack that forwards traffic through ordinary sockets:

Helper Notes
pasta (from the passt project) the default from Podman 5.0; fast, keeps the real client IP address, supports IPv6
slirp4netns the older default; slower, replaces the client address with the helper's

Check which one you use with podman info --format '{{.Host.RootlessNetworkCmd}}', and select one for a container with --network pasta or --network slirp4netns.

Consequences to remember:

  • A rootless container can reach the internet and the host through the helper, but the host's firewall sees the traffic as coming from your user's processes.
  • Published ports are forwarded by a helper process (rootlessport, or pasta's own forwarding). Port forwarding works for TCP and UDP.
  • ICMP ping inside a container may fail with "permission denied" unless the sysctl net.ipv4.ping_group_range includes your group. This is a kernel setting; many distributions enable it, and when not, sudo sysctl -w net.ipv4.ping_group_range="0 2000000000" fixes it.
  • Containers can reach services on the host through a special name: with pasta, use host.containers.internal (Podman adds it to the container's /etc/hosts).
  • Networks you create (podman network create) work rootless, and containers on one network find each other by name through aardvark-dns. Rootless networks cannot be reached from other machines unless you publish ports.

Here is a stand-in that checks a few of these rules against a port request. It is JavaScript, not a Podman feature.

JS Stand-in: can this rootless user publish the port?

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Where rootless storage lives

Rootless images and containers are in your home directory, so they follow your quota and your backups:

Terminal
podman info --format '{{.Store.GraphRoot}}'    # usually ~/.local/share/containers/storage
podman info --format '{{.Store.RunRoot}}'      # usually /run/user/1000/containers
podman system df
  • Graph driver: with Linux 5.13 or newer, Podman can use the kernel's overlay driver rootless directly. On older kernels it needs fuse-overlayfs. Without either, it falls back to vfs, which copies whole layers: extremely slow and space-hungry.
  • Home directories on network file systems (NFS, some encrypted or FUSE mounts) often do not support the extended attributes and features overlay needs. The fix is to point graphroot in ~/.config/containers/storage.conf to a local disk.
  • Disk quota: rootless storage counts against the user's disk. Run podman system df and prune regularly.

A sample user config:

TOML
# ~/.config/containers/storage.conf
[storage]
driver = "overlay"
graphroot = "/data/alice/containers/storage"
runroot = "/run/user/1000/containers"

After changing the graph root, previous images are no longer visible (they are still in the old place). Run podman system reset only if you want to delete everything.

Resource limits and cgroups

Memory, CPU and process limits use cgroups. A rootless user can use them only if systemd delegates controllers to the user's slice, and cgroups v2 is required. Check with:

Terminal
cat /sys/fs/cgroup/user.slice/user-$(id -u).slice/user@$(id -u).service/cgroup.controllers

Most distributions delegate memory and pids by default, while cpu and io may need an override:

INI
# /etc/systemd/system/[email protected]/delegate.conf
[Service]
Delegate=memory pids cpu cpuset io

Then log out and in again. If a limit cannot be applied, podman run --cpus 1 ... prints a warning that the limit is discarded, which is a signal to fix delegation rather than ignore it.

Services after you log out

A rootless container is a child of your user's systemd instance. When you log out of the last session, systemd stops that instance and your containers stop with it, unless you enable lingering:

Terminal
loginctl enable-linger "$USER"
loginctl show-user "$USER" --property=Linger

With linger on, user services and their containers start at boot and keep running without a login. This is the standard way to run a rootless service on a server.

Here is one more stand-in: a checklist that turns facts about a machine into recommendations.

JS Stand-in: rootless readiness checklist

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Why does podman run -p 80:80 ... fail for a normal user on a default Linux kernel?

    Only privileged processes may bind low ports. Use a high port, a firewall redirect, or an administrator can lower the sysctl.
  2. 2. Which helper provides the network for rootless containers by default in Podman 5?

    pasta replaced slirp4netns as the default; it is faster and keeps client addresses.
  3. 3. Where does rootless Podman keep images by default?

    Rootless storage is in the user's home, which is why quotas and slow home file systems matter.
  4. 4. Your rootless container stops when you log out of SSH. What fixes this?

    Without lingering, the user's systemd instance ends with the last session and takes the containers with it.
  5. 5. A --cpus limit is ignored in rootless mode. What is a likely cause?

    Rootless cgroup control needs cgroups v2 and delegation of the controller you want.

Summary

  • Rootless users cannot bind ports below 1024 unless the kernel threshold is lowered; usually use a high port or a redirect.
  • Rootless networking uses pasta (or slirp4netns): fine for most uses, with a few differences such as ping and host access.
  • Storage is under ~/.local/share/containers/storage; avoid network file systems and the vfs driver.
  • Resource limits need cgroups v2 and delegated controllers.
  • loginctl enable-linger keeps rootless services alive after logout and starts them at boot.

Next: SELinux, Seccomp and Capabilities