هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
$ مستخدم عادي# بصلاحية root (أو مع sudo)
Know it before you install
Every podman command starts the container itself (no daemon). A rootless container runs as your user, mapped to a range of sub-UIDs; even "root" inside the container is only your user outside. Pods group containers that share a network, like in Kubernetes.
| Item | Value |
|---|---|
| Packages | RHEL: container-tools (podman, buildah, skopeo); Ubuntu: podman |
| Registries | /etc/containers/registries.conf (user: ~/.config/containers/registries.conf) |
| Storage | rootless: ~/.local/share/containers/; root: /var/lib/containers/ |
| Quadlet files | rootless: ~/.config/containers/systemd/; root: /etc/containers/systemd/ |
| Sub-IDs | /etc/subuid, /etc/subgid |
| Docker API (optional) | podman.socket (systemctl --user enable --now podman.socket) |
Install on RHEL, Rocky, Alma and Fedora
Install on Ubuntu and Debian
apt-get update
apt-get install -y podman uidmap slirp4netns
podman --versionFirst configuration: rootless and registries
1. Sub-IDs for your user. useradd adds them for new users. Check, and add them for older users:
grep "^$USER:" /etc/subuid /etc/subgid
/etc/subuid:alice:100000:65536
/etc/subgid:alice:100000:65536
usermod --add-subuids 100000-165535 --add-subgids 100000-165535 alice
podman system migrate2. Registries. Always use full image names (docker.io/library/nginx, registry.access.redhat.com/ubi9/ubi). Short names are allowed only from the search list:
unqualified-search-registries = ["registry.access.redhat.com", "docker.io"]
short-name-mode = "enforcing"3. Log in to private registries:
4. Keep rootless containers running after logout (for services):
loginctl enable-linger aliceDaily use: containers, images and pods
podman run -d --name web -p 8080:80 docker.io/library/nginx:1.27
podman ps -a
podman logs -f web
podman exec -it web sh
podman stop web && podman rm web
podman images
podman build -t shop:dev .
podman volume create pgdata
podman run -d --name db -e POSTGRES_PASSWORD=change-me -v pgdata:/var/lib/postgresql/data docker.io/library/postgres:16
podman run -d --name site -p 8081:80 -v ./site:/usr/share/nginx/html:Z docker.io/library/nginx:1.27Pods — containers that share localhost, like in Kubernetes:
podman pod create --name shop -p 8080:80
podman run -d --pod shop --name app docker.io/library/nginx:1.27
podman run -d --pod shop --name cache docker.io/library/redis:7
podman pod ps
podman kube generate shop > shop.yaml
podman kube play shop.yamlتذكّر
:Z on a bind mount gives the folder the right SELinux label for this container. Without it, SELinux blocks access on RHEL.
Run a container as a service (Quadlet)
Quadlet turns a small file into a systemd service. Rootless example:
[Unit]
Description=Nginx web container
[Container]
Image=docker.io/library/nginx:1.27
ContainerName=web
PublishPort=8080:80
Volume=%h/site:/usr/share/nginx/html:Z
AutoUpdate=registry
[Service]
Restart=always
[Install]
WantedBy=default.targetsystemctl --user daemon-reload
systemctl --user start web
systemctl --user status web
journalctl --user -u web -f
systemctl --user enable --now podman-auto-update.timer(For root containers put the file in /etc/containers/systemd/ and use systemctl without --user. podman generate systemd is the old way and is deprecated.)
Real uses at work:
- Run small services on RHEL servers as systemd units — no Docker daemon, no root.
- Build images in CI without privileges (
podman build/buildah). - Test Kubernetes YAML locally with
podman kube play.
Make it safe
Security checklist:
- Rootless by default; root containers only when really needed.
- Full image names, fixed tags or digests;
short-name-mode = "enforcing". - SELinux on;
:Z/:zfor bind mounts; no--privileged. - Drop rights:
--cap-drop=all --read-only --security-opt no-new-privileges. - Sign and verify images (
podman image sign,policy.json) in strict environments. - Scan images with Trivy; update with
podman auto-update.
Update and remove
dnf -y upgrade container-tools
apt-get install --only-upgrade -y podman
podman system prune -a
podman system reset
dnf -y remove container-toolspodman system reset deletes all your containers, images and volumes.
Fix common problems
| Problem | Cause | Fix |
|---|---|---|
short-name "nginx" did not resolve to an alias and no unqualified-search registries are defined | Short image name in enforcing mode. | Use the full name: docker.io/library/nginx:1.27. |
rootlessport cannot expose privileged port 80 | Rootless users can not bind ports below 1024. | Use 8080; or sysctl net.ipv4.ip_unprivileged_port_start=80; or a root container / proxy. |
cannot find newuidmap / there might not be enough IDs available | uidmap missing or no sub-IDs. | Install uidmap (Ubuntu) / shadow-utils; add sub-IDs; podman system migrate. |
| Rootless containers stop after logout | No lingering. | loginctl enable-linger USER. |
Permission denied on a bind mount | SELinux label or UID mapping. | :Z; for ownership inside use podman unshare chown 1000:1000 ./data. |
docker-compose can not connect | No Docker API socket. | systemctl --user enable --now podman.socket; export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/podman/podman.sock. |
| Quadlet service "not found" | Wrong folder or no daemon-reload. | Check the path; systemctl --user daemon-reload; /usr/libexec/podman/quadlet -dryrun -user. |
Next steps
- Quick how-tos: Rootless containers with Podman, A container as a systemd service.
- Command pages: podman, buildah, skopeo.
- Podman for RHCSA: RH134 — Run containers. Practise: Lab: RH134 review — storage, SELinux, schedules and containers.
- Podman at work: Docker without a daemon.
- The Docker way: Install and set up Docker Engine. Scan the images: Install and set up Trivy.
1What is the main difference between Podman and Docker?
Podman has no daemon and runs containers rootless by default; Docker uses a root daemon.
2How do you make a rootless Podman container start at boot?
A Quadlet .container file in ~/.config/containers/systemd/, systemctl --user enable, and loginctl enable-linger USER.