متقدم
البحث فيأدلة التثبيت
طريقة البحث
  • الصق رسالة الخطأ بين علامتي تنصيص، مثل "permission denied"، لتجد جدول الحل.
  • اختر مجالًا وجزءًا من الدليل (التثبيت، أول الإعدادات، الاستخدام اليومي، الأمان، الحلول) لتصل مباشرة إلى الخطوة الصحيحة.
  • "كلمتان" تجد العبارة بالضبط.
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث
جرّب:

الدليل 29Podman · Containers

Install and set up Podman (rootless containers)

Podman runs containers like Docker — almost the same commands — but without a background daemon and, by default, without root. It is the container engine of RHEL and the RHCSA exam, and it runs containers as normal systemd services with Quadlet. This guide installs Podman on RHEL and Ubuntu, sets up rootless use and registries, runs containers and pods, makes a container start at boot, and covers the fixes for rootless problems.

  • 10 الدروس
  • 13 الأوامر

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

$ مستخدم عادي# بصلاحية root (أو مع sudo)

29.1

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.

ItemValue
PackagesRHEL: container-tools (podman, buildah, skopeo); Ubuntu: podman
Registries/etc/containers/registries.conf (user: ~/.config/containers/registries.conf)
Storagerootless: ~/.local/share/containers/; root: /var/lib/containers/
Quadlet filesrootless: ~/.config/containers/systemd/; root: /etc/containers/systemd/
Sub-IDs/etc/subuid, /etc/subgid
Docker API (optional)podman.socket (systemctl --user enable --now podman.socket)

29.2

Install on RHEL, Rocky, Alma and Fedora

dnf -y install container-tools
podman --version
podman info --format '{{.Host.Security.Rootless}}'
true

الأوامر في هذا الدرس

29.3

Install on Ubuntu and Debian

apt-get update
apt-get install -y podman uidmap slirp4netns
podman --version

الأوامر في هذا الدرس

29.4

First 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 migrate

2. 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:

/etc/containers/registries.conf
unqualified-search-registries = ["registry.access.redhat.com", "docker.io"]
short-name-mode = "enforcing"

3. Log in to private registries:

podman login registry.example.com
cat ${XDG_RUNTIME_DIR}/containers/auth.json

4. Keep rootless containers running after logout (for services):

loginctl enable-linger alice

29.5

Daily 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.27

Pods — 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.

الأوامر في هذا الدرس

29.6

Run a container as a service (Quadlet)

Quadlet turns a small file into a systemd service. Rootless example:

~/.config/containers/systemd/web.container
[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.target
systemctl --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.

29.7

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/:z for 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.

الأوامر في هذا الدرس

29.8

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-tools

podman system reset deletes all your containers, images and volumes.

الأوامر في هذا الدرس

29.9

Fix common problems

ProblemCauseFix
short-name "nginx" did not resolve to an alias and no unqualified-search registries are definedShort image name in enforcing mode.Use the full name: docker.io/library/nginx:1.27.
rootlessport cannot expose privileged port 80Rootless 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 availableuidmap missing or no sub-IDs.Install uidmap (Ubuntu) / shadow-utils; add sub-IDs; podman system migrate.
Rootless containers stop after logoutNo lingering.loginctl enable-linger USER.
Permission denied on a bind mountSELinux label or UID mapping.:Z; for ownership inside use podman unshare chown 1000:1000 ./data.
docker-compose can not connectNo 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.

29.10

Next steps

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.

كل الأوامر في هذا الفصل