Skip to main content

Podman Cheat Sheet

Shenzhen, China

For more information about podman, visit the Red Hat Developer website. This cheat sheet was written by Doug Tidwell, with huge thanks to Dan Walsh and Scott McCarty.

In the following container is either a container name or a container ID. If tag is omitted in image:tag , the default value is latest.

Finding Images

CommandDescription
podman imagesList all local images
podman history image:tagDisplay information about how an image was built
podman login registryURL -u username [-p password]Log in to a remote registry
podman pull registry/username/image:tagPull an image from a remote registry
podman search searchStringSearch local cache and remote registries for images
podman logoutLog out of the current remote registry

The list of registries is defined in /etc/containers/registries.conf

Building Images

CommandDescription
podman build -t image:tag .Build and tag an image using the instructions in Docker?le in the
current directory
podman build -t image:tag -f Dockerfile2Same as above, but with a di?erent Docker?le
podman tag image:tag image:tag2Add an additional name to a local image
podman tag image:tag registry/username/image:tagSame as above, but the additional name includes a remote registry
podman push registry/username/image:tagPush an image to a remote registry

Running Containers on Images

CommandDescription
podman run --rm -it [--name name] image:tag commandRun a container based on a given image.
  • --rm Remove the container after it exits
  • -it Connect the container to the terminal
  • --name name Give the container a name
  • image:tag The image used to create the container
  • command A command to run (/bin/bash for example)
  • -d Run the container in the background
  • -p 8080:32000 Expose container port 8080 as localhost:32000
  • -v /var/lib/mydb:/var/lib/db Map the /var/lib/mydb directory on localhost to a volume named /var/lib/db inside the container
CommandDescription
podman commit container newImage:tagCreate a new image based on the current state of a running container
podman create [--name name] image:tagCreate (but don’t start) a container from an image
podman start containerStart an existing container from an image
podman restart containerRestart an existing container
podman wait container1 [container2… ]Wait on one or more containers to stop
podman stop containerStop a running container gracefully
podman kill containerSend a signal to a running container
podman rm [-f] containerRemove a container (use -f if the container is running)
podman stats containerDisplay a live stream of a container’s resource usage
podman inspect containerReturn metadata (in JSON) about a running container

Working with Container Processes

CommandDescription
podman ps [--all]List the running containers on the system (use --all to include non-
running containers)
podman attach containerAttach to a running container and view its output or control it
    • detaches from the container but leaves it running. | | podman exec container command | Execute a command in a running container | | podman top container | Display the running processes of a container | | podman logs [-tail] container | Display the logs of a container | | podman pause container / podman unpause container | Pause/unpause all the processes in a container | | podman port container | List the port mappings from a container to localhost |

Working with the Container Filesystem

CommandDescription
podman diff containerDisplay all the changes to a container’s ?lesystem
podman cp source targetCopy ?les and folders between a container and localhost
podman mount container / podman umount containerMount or unmount a container’s root ?lesystem
podman import tarballImport a tarball and save it as a ?lesystem image
podman export [-o outputFile] containerExport the container’s ?lesystem to a tar ?le
podman save [-o archiveFile] [--format docker-archiveoci-archive
podman load -i archiveFileLoad a saved image from docker-archive or another format

Removing Images

CommandDescription
podman rmi [-f] image:tagRemove a local image from local cache (use -f to force removal)
podman rmi [-f] registry/username/image:tagRemove a remote image from local cache (use -f to force removal)

Miscellaneous

CommandDescription
podman versionDisplay podman version information
podman infoDisplay information about the podman environment