Ben the DBA

Quick Setup and Basic Containers with Podman

🐳 Container Management

Pull and Run Containers


podman pull nginx:latest
podman run -d --name webserver nginx
podman run -d --name db -e POSTGRES_PASSWORD=test postgres

Basic Operations


podman ps -a                  # List all containers
podman start/stop webserver   # Start or stop a container
podman restart webserver      # Restart a container
podman rm webserver           # Remove a container

Logs and monitoring


podman logs webserver
podman logs -f webserver
podman stats
podman top webserver

🌐 Network Setup

Network isolation and container communication.

Network basics


podman network ls
podman network create my_net
podman network inspect my_net

Container Networking


podman run -d --name web --network my_net -p 8080:80 nginx
podman run -d --name api --network my_net -p 8000:8000 python-app

Network operations


podman network connect my_net container_name
podman network disconnect my_net container_name
podman port web

📦 Volume Management

Volume operations


podman volume create data_vol  # Create a volume
podman volume ls               # List volumes
podman volume inspect data_vol # Inspect a volume

Mount Volumes


podman run -v data_vol:/data nginx
podman run -v /host/path:/container/path nginx
podman run --mount type=volume,source=data_vol,target=/data nginx

Copy Data


podman cp container:/src/path /dest/path     # Copy from container to host
podman cp /src/path container:/dest/path     # Copy from host to container

⚙️ Resource Control

Memory limits


podman run --memory 512m nginx               # Limit memory usage
podman run --memory-swap 1g nginx            # Limit memory and swap

CPU limits


podman run --cpus 0.5 nginx                  # Restrict CPU usage
podman run --cpu-shares 512 nginx            # Set CPU shares

Process limits


podman run --pids-limit 100 nginx            # Limit number of processes
podman run --ulimit nofile=1024:1024 nginx   # Limit open files

🛠️ Runtime Management

System Maintenance


podman info                                  # View system information
podman system df                             # Show disk usage
podman system prune -a                       # Remove unused data

Container Updates


podman pull nginx:latest                     # Update image
podman container checkpoint my-container     # Save container state
podman container restore my-container        # Restore container state

Security Checks


podman image verify nginx:latest             # Verify image signature
podman generate systemd --name web > container-web.service

📘 Tip: Keep Exploring!

For more details, check out the https://podman.io/

TOC

🐳 Container Management
🌐 Network Setup
📦 Volume Management
⚙️ Resource Control
🛠️ Runtime Management