Geavanceerd
Zoeken inHow-to-gidsen
Zo zoek je
  • Typ de taak in je eigen woorden (poort vinden, firewall openen, schijf vol) of plak een foutmelding tussen aanhalingstekens.
  • Kies "Snel antwoord" om alleen de commando's te zien, of een gebied om in één vakgebied te blijven.
  • "twee woorden" vindt precies die zin.
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken
Probeer:

How-to 142Containers · Podman

How to run containers without root with Podman

With Docker, the daemon runs as root and anyone in the docker group is effectively root. Podman runs containers without a daemon, and rootless: as your normal user, so a container breakout lands in an unprivileged account. On RHEL it is the default container tool. This how-to runs rootless containers, explains user namespaces and ports, and shows the Docker-compatible commands.

  • 5 Lessen
  • 11 Commando's

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

142.1

The quick answer

dnf -y install podman
podman run -d --name web -p 8080:80 docker.io/library/nginx:1.27
podman ps
curl -sI http://127.0.0.1:8080 | head -1
podman top web user huser

podman top … user huser shows: root inside the container, your user (or a sub-ID) outside.

142.2

Step by step

  1. Check rootless is ready — each user needs subordinate ID ranges:
grep "^$USER:" /etc/subuid /etc/subgid
/etc/subuid:alice:100000:65536
/etc/subgid:alice:100000:65536
podman info --format '{{.Host.Security.Rootless}}'
true

New users get the ranges automatically; for old users: usermod --add-subuids 100000-165535 --add-subgids 100000-165535 alice.

  1. Same commands as Docker — podman run/ps/logs/exec/build/push. Use full image names (docker.io/library/nginx) to avoid the "which registry?" prompt.
  2. Ports below 1024 are for root only — use high ports (8080) and a proxy/firewall redirect in front, or (system-wide decision) lower net.ipv4.ip_unprivileged_port_start.
  3. Volumes and SELinux — add :Z for a private label (or :z shared), else SELinux denies access:
mkdir -p ~/site && echo hello > ~/site/index.html
podman run -d --name site -p 8081:80 -v ~/site:/usr/share/nginx/html:Z docker.io/library/nginx:1.27

Files written by the container belong to sub-IDs on the host — use podman unshare chown to fix owners inside the user namespace.

  1. Pods and Compose: podman pod groups containers like a Kubernetes Pod; podman kube play app.yaml runs Kubernetes YAML; podman compose (or docker compose with the Podman socket) runs Compose files.
  2. Keep containers running after logout — rootless containers stop when the user's session ends unless lingering is on:
loginctl enable-linger alice

For real services use Quadlet (next how-to).

142.3

Check that it worked

podman info says rootless true, the container answers on its port, and ps -o user,cmd -C nginx on the host shows your user (or a sub-ID), not root.

142.4

Common problems

ProblemCauseFix
cannot find UID/GID for user / newuidmap errorsNo subuid/subgid ranges.Add ranges with usermod --add-subuids/--add-subgids; podman system migrate.
rootlessport cannot expose privileged port 80Ports < 1024 need root.Use 8080+; redirect in the firewall or a proxy.
Permission denied on a mounted folderSELinux label missing.:Z or :z on the volume.
Containers stop after logoutNo linger.loginctl enable-linger USER, or Quadlet with linger.
short-name resolution enforced promptImage without a registry.Use full names (docker.io/…, quay.io/…).
Scripts call dockerMuscle memory / tools.podman-docker package (alias), or update the scripts.

142.5

Go further

1Why is rootless Podman safer than Docker with the docker group?

Containers run as your normal user (mapped sub-IDs); a breakout does not give root on the host.

2Why can a rootless container not publish port 80?

Ports below 1024 are privileged; use a higher port and a proxy or firewall redirect.

Alle commando's in dit hoofdstuk