Podman Cheat Sheet
Common usage
$ alias docker=podman
$ podman --version # Check version
$ sudo podman login -u USER_NAME REGISTRY_URL
# Login to Registry
$ sudo podman login -u USER_NAME \
-p ${TOKEN} \
REGISTRY_URL
# Login with token or password
# eg: in OpenShift, token can retrive as
# $ TOKEN=$(oc whoami -t)
$ podman logout quay.io # Remove login credentials for registry.redhat.io
$ podman logout --all # Remove login credentials for all registries
$ podman search REGISTRY_URL/IMAGE_NAME
# search for an image in registry
$ sudo podman run --name test -u 1234 \
-p 8080:8080 -d s2i-sample-app
$ sudo podman run -d --name TEST \
quay.io/USER_NAME/IMAGE_NAME:VERSION
# Create a container
$ podman run --privileged quay.io/podman/stable podman run ubi8 echo hello
# The easiest way to run Podman inside of a container is to use the --privileged flag.
$ sudo podman ps # List running containers
$ sudo podman stop CONTAINER_NAME # STOP running containers
$ sudo podman rm CONTAINER_NAME # remove running containers
$ sudo podman rmi IMAGE_NAME # delete container image
$ sudo podman logs CONTAINER_NAME
# check logs of running container
$ sudo podman build -t NAME . # build container image from Dockerfile and spec
$ sudo podman images # see available images
Advanced usage
## Rootful Podman in rootful Podman with --privileged
podman run --privileged quay.io/podman/stable podman run ubi8 echo hello
## added volume
podman run --privileged -v ./mycontainers:/var/lib/containers quay.io/podman/stable podman run ubi8 echo hello
## Rootless Podman in rootful Podman with --privileged
podman run --user podman --privileged quay.io/podman/stable podman run ubi8 echo hello
## Rootful Podman in rootful Podman without --privileged
podman run --cap-add=sys_admin,mknod --device=/dev/fuse --security-opt label=disable quay.io/podman/stable podman run ubi8-minimal echo hello
## Run podman inside podman and check podman version
$ podman run --privileged \
quay.io/podman/stable \
podman version
## Run podman inside podman and using ubi8 image inside.
$ podman run --privileged \
quay.io/podman/stable \
podman run ubi8 echo hello
$ podman run -it --privileged \
docker.io/mysticrenji/podman \
podman version
$ podman run -it --privileged \
docker.io/mysticrenji/podman \
podman run -d docker.io/library/node:12-alpine
$ podman run -it --privileged \
docker.io/mysticrenji/podman \
podman version && git version uptime\
uptime;\
git version;\
git clone https://github.com/mysticrenji/podman-experiments.git;\
cd podman-experiments;\
podman-compose up -d;\
podman-compose down
podman images
Container commands list
Command | Man Page | Description |
---|---|---|
attach | podman-container-attach(1) | Attach to a running container |
checkpoint | podman-container-checkpoint(1) | Checkpoint a container |
cleanup | podman-container-cleanup(1) | Cleanup network and mount points of a container |
commit | podman-container-commit(1) | Commit a container into an image |
cp | podman-container-cp(1) | Copy files/folder into and out of containers |
create | podman-container-create(1) | Create a new container |
diff | podman-container-diff(1) | Inspect changes in a containers file system |
exec | podman-container-exec(1) | Run a process in a container |
exists | podman-container-exists(1) | Check if a container exists |
export | podman-container-export(1) | Export container’s filesystem as a tar archive |
init | podman-container-init(1) | Init a container |
inspect | podman-container-inspect(1) | Display detailed information on a container |
kill | podman-container-kill(1) | Send a signal to containers in container |
List (ps) | podman-container-list(1) | List all of the containers |
logs | podman-container-logs(1) | Fetch logs for a container |
mount | podman-container-mount(1) | Mount a container’s root filesystem |
pause | podman-container-pause(1) | Pause container |
port | podman-container-port(1) | List port mappings for a container |
prune | podman-container-prune(1) | Remove all non running containers |
rename | podman-container-rename(1) | Rename an existing container |
restart | podman-container-restart(1) | Restart a container |
restore | podman-container-restore(1) | Restore a checkpointed container |
rm | podman-container-rm(1) | Remove a container |
run | podman-container-run(1) | Run a command in a new container |
runlabel | podman-container-runlabel(1) | Execute the command described by an image label |
start | podman-container-start(1) | Start a container |
stats | podman-container-stats(1) | Display statistics for a container |
stop | podman-container-stop(1) | Stop a container |
top | podman-container-top(1) | Display running process in container |
unmount | podman-container-unmount(1) | Unmount a container’s root filesystem |
unpause | podman-container-unpause(1) | Unpause all the containers in a pod |
wait | podman-container-wait(1) | Wait for a container to exit |
Pod commands list
Command | Man Page | Description |
---|---|---|
create | podman-pod-create(1) | Create a new pod |
exists | podman-pod-exists(1) | Check if a pod exists |
inspect | podman-pod-inspect(1) | Display detailed information on a pod |
kill | podman-pod-kill(1) | Send a signal to containers in pod |
list | podman-pod-list(1) | List all of the pods |
logs | podman-pod-logs(1) | Fetch logs for pod with one or more containers |
pause | podman-pod-pause(1) | Pause all the containers in a pod |
prune | podman-pod-prune(1) | Remove all stopped pods and their containers |
restart | podman-pod-restart(1) | Restart a pod |
rm | podman-pod-rm(1) | Remove one or more pods |
stats | podman-pod-stats(1) | Display statistics for the containers in a pods |
start | podman-pod-start(1) | Start a pod |
stop | podman-pod-stop(1) | Stop a pod |
top | podman-pod-top(1) | Display running process in the pod |
unpause | podman-pod-unpause(1) | Unpause all the containers in a pod |
Podman on MacOS
## Intall podman and qemu
brew install podman qemu
podman machine init
podman machine start
Reference
https://podman.io/
https://cloudnweb.dev/2019/06/replacing-docker-with-podman-power-of-podman/
https://www.redhat.com/sysadmin/podman-inside-kubernetes
- Podman in Action - The next generation of container engines (Dan Walsh)
Disclaimer
- License under
CC BY-NC 4.0
- Copyright issue feedback
me#imzye.me
, replace # with @ - Not all the commands and scripts are tested in production environment, use at your own risk
- No privacy information is collected here