Podman — Manage Containers Daemonless and Rootless
Practical guide to Podman: manage daemonless, rootless containers and pods — lifecycle, images, volumes, networks and Docker compatibility.
Podman is a container engine that runs without a background daemon: every container is a regular child process of your user rather than something spawned by a central service. That makes rootless operation the default – you start containers without root privileges and shrink the attack surface considerably. Its command line is largely Docker-compatible, so most docker commands work unchanged once you replace docker with podman. On top of that, Podman understands pods, grouping several containers the way Kubernetes does, and can generate matching YAML manifests. This guide takes you from container lifecycle through images, volumes and networks to rootless security and systemd integration.
Container Lifecycle
podman run <image> — Create and start a new container from an image.
podman run nginxpodman run -d <image> — Run a container in detached (background) mode.
podman run -d nginxpodman run -it <image> <command> — Run a container interactively with a TTY.
podman run -it ubuntu bashpodman run --name <name> <image> — Run a container with a custom name.
podman run --name my-web -d nginxpodman run --rm <image> — Automatically remove the container when it exits.
podman run --rm alpine echo "Hello"podman start <container> — Start a stopped container.
podman start my-webpodman stop <container> — Gracefully stop a running container.
podman stop my-webpodman stop -a — Stop all running containers at once.
podman stop -apodman restart <container> — Stop and then start a container again.
podman restart my-webpodman rm <container> — Remove a stopped container.
podman rm my-webpodman rm -f <container> — Force remove a running container.
podman rm -f my-webpodman rm -a — Remove all stopped containers.
podman rm -aPorts, Environment & Resources
podman run -p <host_port>:<container_port> <image> — Map a host port to a container port.
podman run -d -p 8080:80 nginxpodman run -e <KEY>=<value> <image> — Set an environment variable inside the container.
podman run -d -e MYSQL_ROOT_PASSWORD=secret mysql:8podman run --env-file <file> <image> — Load environment variables from a file.
podman run -d --env-file .env my-apppodman run -m <memory> <image> — Set a memory limit for the container.
podman run -d -m 512m nginxpodman run --cpus=<number> <image> — Limit the number of CPU cores the container can use.
podman run -d --cpus=1.5 my-apppodman run --restart=<policy> <image> — Set restart policy: no, on-failure, always, unless-stopped.
podman run -d --restart=always nginxVolumes & Mounts
podman run -v <host_path>:<container_path> <image> — Bind mount a host directory into the container.
podman run -d -v ./html:/usr/share/nginx/html nginxpodman run -v <host_path>:<container_path>:Z <image> — Bind mount with SELinux private label (single container access).
podman run -d -v ./data:/data:Z my-apppodman run -v <host_path>:<container_path>:z <image> — Bind mount with SELinux shared label (multiple containers can access).
podman run -d -v ./shared:/shared:z my-apppodman run -v <volume_name>:<container_path> <image> — Mount a named Podman volume into the container.
podman run -d -v db-data:/var/lib/mysql mysql:8podman volume create <name> — Create a named volume for persistent data storage.
podman volume create db-datapodman volume ls — List all Podman volumes.
podman volume lspodman volume inspect <name> — Show detailed information about a volume.
podman volume inspect db-datapodman volume rm <name> — Remove a volume.
podman volume rm db-datapodman volume prune — Remove all unused volumes.
podman volume pruneListing & Inspecting
podman ps — List all running containers.
podman pspodman ps -a — List all containers including stopped ones.
podman ps -apodman ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" — List containers with custom output format.
podman ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"podman inspect <container> — Show detailed JSON information about a container.
podman inspect my-webpodman port <container> — Show port mappings for a container.
podman port my-webpodman stats — Show live resource usage for all running containers.
podman statspodman top <container> — Show running processes inside a container.
podman top my-webpodman top <container> hpid user args — Show processes with custom ps format descriptors (Podman-specific).
podman top my-web hpid user argsLogs & Exec
podman logs <container> — Show the logs of a container.
podman logs my-webpodman logs -f <container> — Follow log output in real-time.
podman logs -f my-webpodman logs --tail <n> <container> — Show only the last N lines of logs.
podman logs --tail 50 my-webpodman logs --since <time> <container> — Show logs since a timestamp or relative time.
podman logs --since 30m my-webpodman exec -it <container> <command> — Run a command interactively inside a running container.
podman exec -it my-web bashpodman exec <container> <command> — Run a command inside a running container (non-interactive).
podman exec my-web cat /etc/nginx/nginx.confpodman cp <container>:<path> <host_path> — Copy files from a container to the host.
podman cp my-web:/etc/nginx/nginx.conf ./nginx.confpodman cp <host_path> <container>:<path> — Copy files from the host into a container.
podman cp ./index.html my-web:/usr/share/nginx/html/Images
podman images — List all locally available images.
podman imagespodman pull <image> — Download an image from a registry.
podman pull docker.io/library/nginx:alpinepodman push <image> — Upload an image to a registry.
podman push quay.io/myuser/my-app:latestpodman tag <source_image> <target_image> — Create a new tag for an existing image.
podman tag my-app:latest quay.io/myuser/my-app:v1.0podman rmi <image> — Remove a local image.
podman rmi nginx:alpinepodman image prune — Remove all dangling (untagged) images.
podman image prunepodman image prune -a — Remove all images not used by any container.
podman image prune -apodman history <image> — Show the layer history of an image.
podman history nginx:alpinepodman save -o <file> <image> — Export an image to a tar archive.
podman save -o my-app.tar my-app:latestpodman load -i <file> — Import an image from a tar archive.
podman load -i my-app.tarpodman search <term> — Search registries for images matching a term.
podman search nginxBuilding Images
podman build -t <name>:<tag> . — Build an image from a Dockerfile/Containerfile in the current directory.
podman build -t my-app:latest .podman build -t <name> -f <file> . — Build using a specific Dockerfile or Containerfile.
podman build -t my-app -f Containerfile.prod .podman build --no-cache -t <name> . — Build without using the layer cache.
podman build --no-cache -t my-app:latest .podman build --build-arg <KEY>=<value> -t <name> . — Pass a build-time variable to the build.
podman build --build-arg NODE_ENV=production -t my-app .podman build --target <stage> -t <name> . — Build only up to a specific stage in a multi-stage build.
podman build --target builder -t my-app:build .podman build --platform <platform> -t <name> . — Build for a specific platform architecture.
podman build --platform linux/arm64 -t my-app .podman build --layers=false -t <name> . — Build without creating intermediate layers (smaller image, no cache reuse).
podman build --layers=false -t my-app .Pods
podman pod create --name <name> — Create a new pod. Pods group containers that share network and IPC namespaces.
podman pod create --name my-podpodman pod create --name <name> -p <host_port>:<container_port> — Create a pod with published ports. Ports are set at pod level, not container level.
podman pod create --name web-pod -p 8080:80 -p 3306:3306podman run --pod <pod> <image> — Run a container inside an existing pod.
podman run -d --pod my-pod --name web nginxpodman pod ls — List all pods with their status and container count.
podman pod lspodman pod inspect <pod> — Show detailed JSON information about a pod.
podman pod inspect my-podpodman pod start <pod> — Start all containers in a pod.
podman pod start my-podpodman pod stop <pod> — Stop all containers in a pod.
podman pod stop my-podpodman pod restart <pod> — Restart all containers in a pod.
podman pod restart my-podpodman pod rm <pod> — Remove a stopped pod and all its containers.
podman pod rm my-podpodman pod rm -f <pod> — Force remove a pod including running containers.
podman pod rm -f my-podpodman pod top <pod> — Show running processes for all containers in a pod.
podman pod top my-podpodman pod logs <pod> — Show combined logs for all containers in a pod.
podman pod logs my-podNetworks
podman network ls — List all Podman networks.
podman network lspodman network create <name> — Create a new network.
podman network create my-networkpodman network inspect <name> — Show detailed information about a network.
podman network inspect my-networkpodman network connect <network> <container> — Connect a running container to a network.
podman network connect my-network my-webpodman network disconnect <network> <container> — Disconnect a container from a network.
podman network disconnect my-network my-webpodman run --network <name> <image> — Run a container on a specific network.
podman run -d --network my-network --name api my-apipodman network rm <name> — Remove a network.
podman network rm my-networkpodman network prune — Remove all unused networks.
podman network pruneRootless & Security
podman unshare <command> — Run a command in the user namespace used by rootless Podman. Useful for fixing volume permissions.
podman unshare chown 1000:1000 /home/user/datapodman run --userns=keep-id <image> — Map the current user UID/GID into the container. Files created have correct host ownership.
podman run --userns=keep-id -v ./data:/data my-apppodman run --user <uid>:<gid> <image> — Run the container process as a specific user and group.
podman run --user 1000:1000 my-apppodman run --security-opt label=disable <image> — Disable SELinux label confinement for the container. Weakens isolation – use deliberately, e.g. to work around a specific volume-mount issue.
podman run --security-opt label=disable -v ./data:/data my-apppodman run --cap-add <capability> <image> — Add a Linux capability to the container.
podman run --cap-add NET_ADMIN my-apppodman run --cap-drop ALL <image> — Drop all Linux capabilities for maximum security.
podman run --cap-drop ALL --cap-add NET_BIND_SERVICE my-apppodman run --read-only <image> — Mount the container root filesystem as read-only.
podman run --read-only --tmpfs /tmp my-appSystemd Integration
For new setups Podman recommends Quadlet (declarative .container files) over generate systemd since version 4.4; the generate systemd commands below still work and remain useful for existing units.
podman generate systemd --new --name <container> — Generate a systemd unit file that creates a fresh container on start.
podman generate systemd --new --name my-webpodman generate systemd --new --name <container> --files — Generate systemd unit file and write it to disk.
podman generate systemd --new --name my-web --filespodman generate systemd --new --name <pod> --files — Generate systemd unit files for an entire pod and its containers.
podman generate systemd --new --name my-pod --filespodman auto-update — Automatically update containers with the io.containers.autoupdate label.
podman auto-updatepodman auto-update --dry-run — Check which containers would be updated without applying changes.
podman auto-update --dry-runpodman generate kube <pod> — Generate a Kubernetes YAML definition from a pod or container.
podman generate kube my-pod > my-pod.yamlpodman play kube <file> — Create pods and containers from a Kubernetes YAML file.
podman play kube my-pod.yamlpodman play kube --down <file> — Tear down pods and containers created from a Kubernetes YAML file.
podman play kube --down my-pod.yamlPodman Compose
podman compose up -d — Start all services defined in docker-compose.yml in detached mode.
podman compose up -dpodman compose down — Stop and remove all containers and networks from the Compose project.
podman compose downpodman compose ps — List containers managed by the Compose project.
podman compose pspodman compose logs -f — Follow logs for all services in real-time.
podman compose logs -fpodman compose exec <service> <command> — Execute a command inside a running Compose service container.
podman compose exec web bashpodman compose build — Build or rebuild all service images.
podman compose buildCleanup & System
podman system df — Show disk usage: images, containers, volumes.
podman system dfpodman system prune — Remove all stopped containers, unused images, and networks.
podman system prunepodman system prune -a --volumes — Full cleanup including all unused images and volumes.
podman system prune -a --volumespodman system reset — Reset Podman storage back to initial state. Removes all containers, images, and volumes.
podman system resetpodman system migrate — Migrate containers to the latest version format after a Podman upgrade.
podman system migratepodman info — Show system-wide Podman information (version, storage, registries, etc.).
podman infopodman version — Show Podman version details.
podman versionpodman login <registry> — Log in to a container registry.
podman login quay.iopodman logout <registry> — Log out from a container registry.
podman logout quay.ioDocker Compatibility
alias docker=podman — Create a shell alias so docker commands automatically use Podman.
alias docker=podmanpodman system service --time=0 — Start the Podman API service. Enables compatibility with Docker API clients.
podman system service --time=0 unix:///tmp/podman.sockexport DOCKER_HOST=unix://<socket_path> — Point Docker CLI or docker-compose to the Podman socket.
export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/podman/podman.sock Conclusion
Podman is more than a drop-in replacement for Docker: the daemonless model and rootless operation fit modern security requirements better, while native pod and Kubernetes support bridges the gap to orchestration. If you are coming from Docker, the quickest start is alias docker=podman and carrying on as usual; on servers, the systemd integration via Quadlet or generate systemd pays off for running containers cleanly as services.
Further Reading
- Podman – official documentation – reference and manual
- Podman – project site – downloads, installation and news
- Podman – Wikipedia – background and architecture
Related Commands
- ddev – container-based local development environments
- docker – the classic daemon-based container engine
- docker-compose – define multi-container applications declaratively