Cheatsheet - Podman
Podman is a powerful, daemonless container engine for developing, managing, and running OCI containers on your Linux System. For those familiar with Docker, many of the commands will be intuitive, as Podman is command-line compatible with Docker. This cheat sheet provides a quick reference for a wide range of common Podman commands.
Managing Containers
Command | Description |
---|---|
podman run [options] <image> [command] |
Create and run a new container from an image. |
podman ps |
List all running containers. |
podman ps -a |
List all containers, including stopped ones. |
podman start <container> |
Start one or more stopped containers. |
podman stop <container> |
Stop one or more running containers. |
podman restart <container> |
Restart one or more containers. |
podman rm <container> |
Remove one or more containers. |
podman exec -it <container> <command> |
Execute a command inside a running container. |
podman logs <container> |
Fetch the logs of a container. |
podman inspect <container> |
Display detailed information on a container. |
podman top <container> |
Display the running processes of a container. |
podman stats |
Display a live stream of container resource usage statistics. Note: This may require sudo to show containers running with root privileges. |
podman attach <container> |
Attach to a running container. |
podman wait <container> |
Block until one or more containers stop, then print their exit codes. |
podman port <container> |
List port mappings for a container. |
podman rename <container> <new_name> |
Rename an existing container. |
Managing Images
Command | Description |
---|---|
podman images |
List all images in local storage. |
podman pull <image> |
Pull an image from a registry. |
podman push <image> <destination> |
Push an image to a specified destination. |
podman rmi <image> |
Remove one or more images. |
podman build -t <image_name> <path> |
Build an image using a Dockerfile. |
podman commit <container> <new_image> |
Create a new image from a container's changes. |
podman tag <image> <new_tag> |
Add an additional name to a local image. |
podman history <image> |
Show the history of an image. |
podman search <term> |
Search registries for an image. |
podman import <fileurl> <image_name> |
Import a tarball to create a filesystem image. |
podman export <container> |
Export a container's filesystem as a tar archive. |
podman save -o <output_file> <image> |
Save an image to a tar archive. |
podman load -i <input_file> |
Load an image from a tar archive. |
Working with Pods
Pods are a group of one or more containers that share the same network, PID, and IPC namespaces.
Command | Description |
---|---|
podman pod create [options] |
Create a new pod. |
podman pod ps |
List all running pods. |
podman pod start <pod> |
Start one or more stopped pods. |
podman pod stop <pod> |
Stop one or more running pods. |
podman pod restart <pod> |
Restart one or more pods. |
podman pod rm <pod> |
Remove one or more pods. |
podman pod inspect <pod> |
Display detailed information on a pod. |
podman pod top <pod> |
Display the running processes of containers in a pod. |
podman generate kube <pod> |
Generate Kubernetes YAML from a pod. |
podman play kube <yaml_file> |
Create and run a pod from a Kubernetes YAML file. |
Networking
Command | Description |
---|---|
podman network create <network_name> |
Create a new network. |
podman network ls |
List networks. |
podman network rm <network_name> |
Remove one or more networks. |
podman network inspect <network_name> |
Display detailed information on a network. |
podman network connect <network_name> <container> |
Connect a container to a network. |
podman network disconnect <network_name> <container> |
Disconnect a container from a network. |
Volumes
Command | Description |
---|---|
podman volume create <volume_name> |
Create a new volume. |
podman volume ls |
List volumes. |
podman volume rm <volume_name> |
Remove one or more volumes. |
podman volume inspect <volume_name> |
Display detailed information on a volume. |
System Commands
Command | Description |
---|---|
podman info |
Display Podman system information. |
podman version |
Display the Podman version information. |
podman login <registry> |
Log in to a container registry. |
podman logout <registry> |
Log out of a container registry. |
podman system prune |
Remove all unused container, image, and network data. |
Rootless Container Commands
Podman is known for its ability to run containers without root privileges.
Command | Description |
---|---|
podman unshare <command> |
Run a command in a modified user namespace. |
podman unshare cat /proc/self/uid_map |
Inspect the UID mapping for the current user. |
podman run --uidmap <user>:<container_user>:1 <image> |
Run a container with a specific UID mapping. |
Troubleshooting
Cannot connect to Podman
The error "Cannot connect to Podman" on macOS typically indicates an issue with Podman's ability to communicate with its underlying virtual machine (VM). Podman on macOS requires a Linux VM to run containers, and the connection error suggests a problem with this VM or the way Podman is trying to interact with it.
Check status o f Podman connections
podman system connection list
If no connection is listed or the status is not as expected, proceed to the next steps. Initialize and Start the Podman Machine.
Ensure the Podman machine is properly initialized and running.
podman machine init
podman machine start