Skip to content

Instantly share code, notes, and snippets.

@waltervargas
Created March 28, 2026 00:27
Show Gist options
  • Select an option

  • Save waltervargas/2a0146a52d846793d96e5c5509307f79 to your computer and use it in GitHub Desktop.

Select an option

Save waltervargas/2a0146a52d846793d96e5c5509307f79 to your computer and use it in GitHub Desktop.
Podman cheat sheet for system administrators

Podman Cheat Sheet

Pods

podman pod ls                          # List all pods
podman pod ps --format "table {{.Name}} {{.Status}} {{.Containers}}"
podman pod create --name mypod -p 8080:80   # Create pod with port mapping
podman pod start <pod>                 # Start a pod
podman pod stop <pod>                  # Stop a pod
podman pod restart <pod>               # Restart a pod
podman pod rm <pod>                    # Remove a pod
podman pod rm --all -f                 # Force remove all pods
podman pod inspect <pod>               # Detailed pod info
podman pod logs <pod>                  # Logs from all containers in pod
podman pod top <pod>                   # Running processes in pod

Containers

podman ps                              # List running containers
podman ps -a                           # List all containers (including stopped)
podman run -d --name myapp image:tag   # Run container in background
podman exec -it <container> /bin/sh    # Shell into a container
podman logs <container>                # View logs
podman logs -f <container>             # Follow logs
podman logs --tail 100 <container>     # Last 100 lines
podman stop <container>                # Stop container
podman start <container>               # Start container
podman restart <container>             # Restart container
podman rm <container>                  # Remove container
podman rm --all -f                     # Force remove all containers
podman inspect <container>             # Detailed container info
podman top <container>                 # Running processes
podman stats                           # Live resource usage (CPU/MEM/NET/IO)
podman cp <container>:/path /local     # Copy file from container
podman cp /local <container>:/path     # Copy file to container

Images

podman images                          # List images
podman pull <image>                    # Pull an image
podman build -t myimage .              # Build from Dockerfile
podman image prune -f                  # Remove dangling images
podman image prune --all -f            # Remove all unused images
podman rmi <image>                     # Remove specific image
podman image inspect <image>           # Image details
podman tag <image> newname:tag         # Tag an image

Volumes

podman volume ls                       # List volumes
podman volume create <name>            # Create volume
podman volume inspect <name>           # Volume details
podman volume rm <name>                # Remove volume
podman volume prune -f                 # Remove unused volumes
# Remove all except one:
podman volume ls -q | grep -v '<keep>' | xargs podman volume rm

Networks

podman network ls                      # List networks
podman network create <name>           # Create network
podman network inspect <name>          # Network details
podman network rm <name>               # Remove network
podman network prune -f                # Remove unused networks

Disk Space and Cleanup

podman system df                       # Disk usage summary
podman system prune -f                 # Remove unused containers/images
podman system prune --all -f           # Remove ALL unused data
podman system prune --all --volumes -f # Nuclear: remove everything unused
podman system reset                    # Factory reset (removes EVERYTHING)

Bulk Operations

# Stop all pods
podman pod ls -q | xargs podman pod stop

# Remove all stopped containers
podman container prune -f

# Restart all pods
podman pod ls -q | xargs podman pod restart

# Kill containers not responding to stop
podman pod stop --timeout 10 <pod>

Compose / Kube

podman-compose up -d                   # Start from docker-compose.yml
podman-compose down                    # Stop and remove
podman generate kube <pod> > pod.yaml  # Export pod to k8s YAML
podman play kube pod.yaml              # Create pod from k8s YAML
podman play kube --down pod.yaml       # Tear down pod from YAML

Debugging

podman logs --since 5m <container>     # Logs from last 5 minutes
podman events                          # Real-time system events
podman healthcheck run <container>     # Run healthcheck manually
podman inspect --format '{{.State.Status}}' <container>   # Get status
podman inspect --format '{{.NetworkSettings.IPAddress}}' <container>  # Get IP

Node.js Debugging Inside Container

# Shell into the container
podman exec -it <container> /bin/sh

# Enable debugger on running node process
kill -USR1 <node_pid>

# Attach node inspector
node inspect 127.0.0.1:9229

# Debugger commands:
# repl        - enter JS console in server context
# sb(file, n) - set breakpoint at file:line
# cb(file, n) - clear breakpoint
# list(n)     - show n lines around current position (requires paused execution)
# n           - step next
# s           - step into
# o           - step out
# c           - continue
# Ctrl+C      - leave repl mode

Systemd Integration

podman generate systemd --new <pod> > pod.service   # Generate unit file
systemctl --user enable --now pod.service            # Enable and start
systemctl --user status pod.service                  # Check status
loginctl enable-linger <user>                        # Keep running after logout

Database Operations

Access PostgreSQL Inside Container

podman exec -it <postgres-container> psql -U root -d db_dev

Create Test/Bot Users

podman exec -it <postgres-container> psql -U root -d db_dev -c "
INSERT INTO users (username, name, email, password_hash, terms_accepted_at)
SELECT 'bot' || i, 'Bot ' || i, 'bot' || i || '@test.com',
  (SELECT password_hash FROM users LIMIT 1), NOW()
FROM generate_series(1,7) AS i;
"

This creates 7 bot users reusing the password hash from an existing user (default seed password: 123321Pa).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment