هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
ماذا يفعل
Podman is the container engine of RHEL. The commands are the same as Docker's (alias docker=podman works for most scripts), but there is no background service: every container is a normal child process, and a normal user can run containers in his own user namespace.
Images come from registries (registry.access.redhat.com, registry.redhat.io, quay.io …). Use full image names. Data that must stay goes into volumes or host folders mounted with -v DIR:DIR:Z (the :Z gives the folder the right SELinux label). To start containers at boot, write a Quadlet file (.container) for systemd. Each sub-command has its own man page: man podman-run, man podman-build …
طريقة الكتابة
podman [GLOBAL OPTION]... COMMAND [OPTION]... [ARG]...
podman run [OPTION]... IMAGE [COMMAND [ARG]...]
podman build [OPTION]... [CONTEXT]الأجزاء الرئيسية
Containers
runIMAGE[CMD]- Create and start a new container from an image.
createIMAGE- Create a container but do not start it.
start/stop/restartNAME- Start, stop or restart containers.
ps- List containers (
-aalso stopped ones). logsNAME- Show the output (logs) of a container.
execNAMECMD- Run a command inside a running container.
attachNAME- Connect to the main process of a container.
topNAME- Show the processes inside a container.
stats- Live CPU, memory and network use of containers.
inspectNAME- All details of a container (or image, volume, network) as JSON.
portNAME- Show the published ports.
cpSRCDST- Copy files between a container and the host.
diffNAME- Files changed in a container.
killNAME- Send a signal to the main process.
pause/unpauseNAME- Freeze / continue all processes.
renameOLDNEW- Rename a container.
rmNAME- Remove containers (
-falso running ones). waitNAME- Wait until a container stops, print its exit code.
commitNAMEIMAGE- Make a new image from a changed container.
exportNAME- Save the file system of a container as a tar archive.
healthcheckrunNAME- Run the health check of a container now.
updateNAME- Change CPU and memory limits of a container.
containerprune- Remove all stopped containers.
Images
images- List local images.
pullIMAGE- Download an image.
pushIMAGE[DEST]- Upload an image to a registry.
build[DIR]- Build an image from a Containerfile.
searchTERM- Search a registry.
tagIMAGENEWNAME- Give an image another name.
untagIMAGE- Remove names from an image.
rmiIMAGE- Remove local images.
historyIMAGE- Show the layers of an image.
save/load- Write images to a tar archive / read them back.
importFILE- Make an image from a tar archive.
imageprune- Remove images that no container uses.
login/logoutREGISTRY- Log in to / out of a registry.
manifest- Work with multi-architecture image lists.
Storage, network and pods
volumecreate/ls/inspect/rm/prune- Manage named volumes.
networkcreate/ls/inspect/rm/connect- Manage container networks.
secretcreate/ls/rm- Store passwords and keys for containers.
podcreate/ps/start/stop/rm- Groups of containers that share a network.
kubeplayFILE- Run containers and pods from a Kubernetes YAML file.
kubegenerateNAME- Write Kubernetes YAML for a container or pod.
System
info- Information about the host, storage and registries.
version- The Podman version.
systemdf- Disk space used by images, containers and volumes.
systemprune- Remove everything that is not used.
systemreset- Delete all containers, images and volumes of this user.
systemmigrate- Move containers to a new Podman version (rootless).
events- Show container events live.
auto-update- Pull newer images and restart containers that use the auto-update label.
generatesystemdNAME- Write a systemd unit (deprecated: use Quadlet).
unshareCMD- Run a command inside the user namespace of rootless Podman.
mount/unmountNAME- Mount the file system of a container (root or
podman unshare). machine- Manage the Podman virtual machine (macOS and Windows).
completionSHELL- Make shell completion scripts.
الخيارات 138
الأكثر استخدامًا
Global options
podman run / create: start and identity
podman run / create: environment and files
--image-volume=MODE- What to do with volumes in the image:
bind,tmpfs,ignore.
podman run / create: network and ports
--network=MODEbridge, a named network,host,none,pasta(rootless default),container:NAME.
podman run / create: limits and security
--userns=MODE- User namespace:
keep-id,auto,host,nomap. --pid=MODE/--ipc=MODE/--uts=MODE/--cgroupns=MODE- Share namespaces with the host or a container.
podman ps
podman logs
podman exec
podman images
podman build
-q,--quiet/--logfile=FILE/--iidfile=FILE/--rm/--force-rm/--jobs=N/--retry=N/--tls-verify/--authfile=FILE/--creds=USER:PASS- More choices (see
man podman-build).
لا يوجد شيء يطابق هذا الفلتر.
أمثلة 14
$ مستخدم عادي# بصلاحية root (أو مع sudo)
1Check that rootless Podman works
podman info --format '{{.Host.Security.Rootless}} {{.Store.GraphRoot}}' true /home/student/.local/share/containers/storageRootless containers and images live in your home folder, not in /var/lib/containers.
2Look at an image before you pull it
skopeo inspect docker://registry.access.redhat.com/ubi10/httpd-24 --format '{{.Labels.summary}}' podman pull registry.access.redhat.com/ubi10/httpd-24Always use the full name: registry, namespace, image, tag.
3Run a web server with your own content
mkdir -p ~/site && echo "hello" > ~/site/index.html podman run -d --name site -p 8080:8080 -v ~/site:/var/www/html:Z registry.access.redhat.com/ubi10/httpd-24 curl -s http://localhost:8080/ hello:Zlabels the folder for this container. Without it, SELinux blocks access.4Get a shell in a running container
podman exec -it site /bin/bash bash-5.2$ cat /etc/os-release | head -2Leave the shell with
exit; the container keeps running.5Read the logs of a container
podman logs --tail 20 -f site podman logs --since 10m site6Run a one-time command and delete the container
podman run --rm registry.access.redhat.com/ubi10/ubi cat /etc/redhat-release Red Hat Enterprise Linux release 10.0 (Coughlan)7Find and clean up stopped containers and old images
podman ps -a --filter status=exited --format '{{.Names}} {{.Status}}' podman container prune -f podman image prune -f podman system df8Build and push your own image
cat Containerfile FROM registry.access.redhat.com/ubi10/httpd-24 COPY index.html /var/www/html/ podman build -t quay.io/s0sta/site:1.0 . podman login quay.io podman push quay.io/s0sta/site:1.09Limit memory and CPU of a container
podman run -d --name worker --memory 512m --cpus 1 --pids-limit 200 registry.access.redhat.com/ubi10/ubi sleep infinity podman stats --no-stream worker10Run a container with fewer rights (DevSecOps)
podman run --rm --read-only --cap-drop=ALL --security-opt no-new-privileges -u 1001 registry.access.redhat.com/ubi10/ubi id uid=1001(1001) gid=0(root) groups=0(root)Read-only root, no capabilities, no privilege change: a hacked app can do much less.
11Keep data in a named volume
podman volume create pgdata podman run -d --name db -v pgdata:/var/lib/pgsql/data:Z -e POSTGRESQL_USER=app -e POSTGRESQL_PASSWORD=secret -e POSTGRESQL_DATABASE=app registry.redhat.io/rhel10/postgresql-16 podman volume inspect pgdata --format '{{.Mountpoint}}'12Start a container at boot with Quadlet
mkdir -p ~/.config/containers/systemd cat ~/.config/containers/systemd/site.container [Container] Image=registry.access.redhat.com/ubi10/httpd-24 PublishPort=8080:8080 Volume=%h/site:/var/www/html:Z [Install] WantedBy=default.target systemctl --user daemon-reload systemctl --user start site.service loginctl enable-linger studentLinger keeps the user's services running without a login and after a reboot.
13Copy a file out of a container
podman cp site:/etc/httpd/conf/httpd.conf ./httpd.conf podman diff site | head14Run a Kubernetes YAML file
podman kube generate site > site.yaml podman kube play site.yaml podman kube down site.yaml
لا يوجد شيء يطابق هذا الفلتر.
انتبه
- Rootless containers can not bind host ports below 1024. Use 8080 / 8443, or a firewalld port forward.
--privilegedand-v /:/hostgive a container almost full control of the host. Avoid them.- A container's own file system is deleted with
podman rm. Keep data in volumes or host folders. podman generate systemdis deprecated. Use Quadlet files.- Images from
registry.redhat.ioneedpodman loginwith a Red Hat account; UBI images fromregistry.access.redhat.comdo not.
الملفات
/etc/containers/registries.conf- Registries and the search list for short names.
/etc/containers/containers.conf, ~/.config/containers/containers.conf- Defaults of Podman.
/etc/containers/storage.conf- Storage driver and places.
~/.config/containers/systemd/, /etc/containers/systemd/- Quadlet files (user / root).
/etc/subuid, /etc/subgid- ID ranges for rootless containers.
$XDG_RUNTIME_DIR/containers/auth.json- Saved registry logins.
نصائح للحفظ
podman ps --format '{{.Names}} {{.Ports}}'gives a short, script-friendly list.podman auto-updatewith the labelio.containers.autoupdate=registryupdates Quadlet containers when a new image is pushed.podman unshare ls -l ~/.local/share/containersshows files with the IDs the containers see.
رموز الخروج
0 | Success. |
125 | Error in Podman itself. |
126 | The command in the container could not be run. |
127 | The command in the container was not found. |
Other | podman run returns the exit code of the container's main process. |