Podman Snippets
# List running containerspodman ps
# See all containerspodman ps -a
# Stop a containerpodman kill container_namepodman kill (podman ps)
# Helppodman --helppodman -h
# Search for imagespodman search search_term
# Pull an image with repository specifiedpodman pull quay.io/podman/hellopodman pull docker.io/library/httpd
# Pull image from Docker Hubpodman pull docker.io/nixos/nix
# List imagespodman images
# Run containerpodman run -dt -p 8080:80/tcp docker.io/library/httpd## -d detached mode## -t pseudo-tty to run commands in interactive shell## -p port forwarding
# Run container with interactive terminalpodman run -it image_name
# Go into container terminalpodman exec it container_name sh
# Run containers and create a kubernetes deployment for thempodman run -d --name web nginxpodman run -d --name db postgres# save deployment.yaml in nushell or bash redirect to new filepodman generate kube web db > deployment.yaml# deployment.yaml can be applied to k8s cluster
# Runs pods locally and view thempodman play kube deployment.yamlpodman pod ps
# See container detailspodman inspect -l
# Stop containerpodman stop container_name_or_id# Stop last started containerpodman stop -l
# Remove containerpodman rm container_name_or_id# Remove last started containerpodman rm -l# Remove multiple containerspodman rm -f container1 container2
# Export pod definitions to k8s yaml likepodman generate kube wordpress-pod > wordpress-pod.yaml
# See processes in a containerpodman top container_id
# List podspodman pod ps
# Create pod, managed namespacepodman pod create --name webapp
# Run pod with redispodman run -d --pod webapp --name redis redis# -d detachedpodman run --rm --pod webapp redis redis-cli -h localhost SET mykey "Hello from Redis"podman run --rm --pod webapp redis redis-cli -h localhost GET mykey
# See details of podpodman pod inspect webapp
# See logspodman logs --container redis
# Volumes - listpodman volume ls
# Volume - createpodman volume create mydata
# Volume - see details of a volume like disk locationpodman volume inspect mydata
# Volume - Run image with volume mydatapodman run -d --name webapp -v mydata:/usr/share/nginx/html nginx
# Volume - clean up unused volumespodman volume prune
Podman Machines
Section titled “Podman Machines”# Podman machine host for Windows, macOS startpodman machine start
# Podman machine stoppodman machine stop
# Podman machine rootful mode, stop and start after for usepodman machine set --rootful
# List Machinespodman machine ls
# Machine informationpodman machine info
# podman machine connectionspodman system connection list
Podman Desktop Setup on Windows with WSL
Section titled “Podman Desktop Setup on Windows with WSL”Source: Windows | Podman Desktop
# pwsh: Enable WSL Feature without default Ubuntu Linuxwsl --updatewsl --install --no-distribution
Restart computer, then in start podman-desktop:
- Run through set up of podman machine
- With WSL choose user mode networking, leave other defaults
- After all setup, in dashboard, verify podman is running
In the background, a default podman machine will be running.
Podman Desktop with Minikube Kubernetes Cluster
Section titled “Podman Desktop with Minikube Kubernetes Cluster”Source: https://podman-desktop.io/docs/minikube
In podman desktop extensions, install minikube extension and make sure minikube is installed
# Check profiles if anyminikube profile list
# If on Windows and WSL, require rootful machinepodman machine stoppodman machine set --rootfulpodman machine start
# Start minikube cluster using podman driverminikube start -d podman
# Check pods and contextminikube kubectl get po -Akubectl config current-contextkubectl get pod
# Open minikube dashboardminikube dashboard
# Stop clusterminikube stop