Podman is a daemonless, rootless container engine that is a drop-in replacement for Docker. It provides a REST API, CLI compatibility, and unique features like pod management and systemd integration.
What Is Podman?
Podman (Pod Manager) is an OCI-compliant container runtime developed by Red Hat. Unlike Docker, it runs without a daemon process and can run containers as a non-root user, making it more secure by default.
Key Features:
- Daemonless architecture (no docker daemon)
- Rootless containers by default
- Docker CLI compatible
- Pod concept (like Kubernetes pods)
- REST API (Docker-compatible + Podman-specific)
- Systemd integration
- Docker Compose support (podman-compose)
- Built-in image signing
Quick Start
# Install Podman
# macOS
brew install podman
podman machine init
podman machine start
# Ubuntu/Debian
sudo apt install podman
# Run a container (same as docker!)
podman run -d -p 8080:80 nginx
podman ps
podman logs <container-id>
Podman REST API
Podman provides both a Docker-compatible API and its own extended API:
import requests
# Enable Podman API socket
# systemctl --user start podman.socket
# Or: podman system service --time 0 &
PODMAN = "http://localhost:8080/v4.0.0/libpod"
DOCKER_COMPAT = "http://localhost:8080/v1.41" # Docker-compatible
# List containers (Podman API)
containers = requests.get(f"{PODMAN}/containers/json").json()
for c in containers:
print(f"Container: {c['Names'][0]}, State: {c['State']}, Image: {c['Image']}")
# Create and start container
new_container = requests.post(f"{PODMAN}/containers/create", json={
"image": "docker.io/library/redis:alpine",
"name": "my-redis",
"portmappings": [{"container_port": 6379, "host_port": 6379}]
}).json()
requests.post(f"{PODMAN}/containers/{new_container['Id']}/start")
Pod Management
# Create a pod (group of containers sharing network)
pod = requests.post(f"{PODMAN}/pods/create", json={
"name": "webapp-pod",
"portmappings": [{"container_port": 8080, "host_port": 8080}]
}).json()
# Add containers to pod
requests.post(f"{PODMAN}/containers/create", json={
"image": "docker.io/library/nginx:alpine",
"name": "web",
"pod": "webapp-pod"
})
requests.post(f"{PODMAN}/containers/create", json={
"image": "docker.io/library/redis:alpine",
"name": "cache",
"pod": "webapp-pod"
})
# Start the entire pod
requests.post(f"{PODMAN}/pods/webapp-pod/start")
# List pods
pods = requests.get(f"{PODMAN}/pods/json").json()
for p in pods:
print(f"Pod: {p['Name']}, Containers: {len(p['Containers'])}, Status: {p['Status']}")
Image Management
# Pull an image
requests.post(f"{PODMAN}/images/pull", params={
"reference": "docker.io/library/python:3.12-slim"
})
# List images
images = requests.get(f"{PODMAN}/images/json").json()
for img in images:
names = img.get("Names", ["<none>"])
size_mb = img["Size"] / 1024 / 1024
print(f"Image: {names[0]}, Size: {size_mb:.1f}MB")
# Build from Dockerfile
import io
requests.post(
f"{PODMAN}/build",
params={"t": "my-app:latest"},
data=open("context.tar", "rb")
)
Generate Kubernetes YAML
# Create a pod
podman pod create --name myapp -p 8080:80
podman create --pod myapp --name web nginx
podman create --pod myapp --name db postgres
# Generate Kubernetes YAML from running pod
podman generate kube myapp > myapp.yaml
# Deploy that YAML to Kubernetes
kubectl apply -f myapp.yaml
# Or play Kubernetes YAML locally
podman play kube myapp.yaml
Podman vs Docker
| Feature | Podman | Docker |
|---|---|---|
| Daemon | No (daemonless) | Yes (dockerd) |
| Root | Rootless default | Root default |
| Pods | Native support | No |
| K8s YAML | Generate/play | No |
| Compose | podman-compose | docker compose |
| Systemd | Native integration | No |
| API | Docker-compat + own | Docker API |
Resources
- Podman Docs
- Podman GitHub — 24K+ stars
- API Reference
Need to scrape web data for your container workflows? Check out my web scraping tools on Apify — production-ready actors for Reddit, Google Maps, and more. Questions? Email me at spinov001@gmail.com
Top comments (0)