podman volume createpodman run -vpodman exec -itpodman cp# Bind mount: host path -> container path $ podman run -d --name db -e MYSQL_ROOT_PASSWORD=redhat \ -v /var/local/mysql-data:/var/lib/mysql:Z \ registry.redhat.io/rhel8/mysql-80 # Named volume, created and managed by Podman $ podman volume create mysql-vol $ podman run -d --name db -e MYSQL_ROOT_PASSWORD=redhat \ -v mysql-vol:/var/lib/mysql \ registry.redhat.io/rhel8/mysql-80
| Option | Effect |
|---|---|
:Z | Relabels the host directory privately, for this one container |
:z | Relabels it as shared, so several containers can use it |
:U | Changes ownership to match the container's user |
:Z. Bind mounts do.:U, or run podman unshare chown 27:27 DIR.| Object | What It Is |
|---|---|
| PersistentVolume (PV) | A piece of actual storage in the cluster |
| PersistentVolumeClaim (PVC) | An application's request for storage |
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: db-data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
The pod asks for "5 GiB, read-write" through the PVC; the cluster finds or provisions a matching PV. Pod definitions stay portable.
| Command | What It Does |
|---|---|
podman exec NAME CMD | Runs one command in a running container |
podman exec -it NAME /bin/bash | Opens an interactive shell in it |
podman attach NAME | Connects your terminal to the container's main process |
podman cp | Copies files between the host and a container |
$ podman exec db mysql --version $ podman cp ./schema.sql db:/tmp/schema.sql # host -> container $ podman cp db:/etc/my.cnf . # container -> host
exec starts a separate process. attach connects to the main process, so your keystrokes go to the application itself.$ podman volume create app-data $ podman run -d --name app -v app-data:/data quay.io/example/app:latest $ podman exec -it app /bin/bash [container]$ ls /data [container]$ exit
Remove and recreate the app container with the same -v app-data:/data, and the data in /data is still there.
$ podman volume ls $ podman volume inspect app-data
sudo ausearch -m avc -ts recent, then add :Z or :z.podman exec generally safer for debugging than podman attach?