Podman is a daemonless container engine that's fully compatible with Docker CLI. It runs containers as rootless by default, provides a Docker-compatible REST API, and can generate systemd units for container management.
Free, open source, by Red Hat. Drop-in replacement for Docker.
Why Use Podman?
- Daemonless — no background process, containers run as child processes
- Rootless by default — enhanced security, no root required
- Docker-compatible — same CLI commands, same API, same images
- Pod support — group containers into pods (like Kubernetes)
- Systemd integration — auto-generate systemd services for containers
- REST API — full Docker-compatible API
Quick Setup
1. Install
# Ubuntu/Debian
sudo apt install podman
# macOS
brew install podman
podman machine init && podman machine start
# Verify
podman --version
2. Enable REST API
# Start API service (rootless)
podman system service --time=0 unix:///tmp/podman.sock &
# Or TCP
podman system service --time=0 tcp:0.0.0.0:8080 &
3. List Containers via API
# Via Unix socket
curl -s --unix-socket /tmp/podman.sock http://d/v4.0.0/libpod/containers/json | jq '.[] | {id: .Id[:12], name: .Names[0], state: .State, image: .Image}'
# Docker-compatible endpoint
curl -s --unix-socket /tmp/podman.sock http://d/v4.0.0/containers/json | jq
4. Run Containers via API
# Create a container
curl -s --unix-socket /tmp/podman.sock -X POST http://d/v4.0.0/libpod/containers/create \
-H "Content-Type: application/json" \
-d '{
"image": "docker.io/library/nginx:latest",
"name": "my-nginx",
"portmappings": [{"container_port": 80, "host_port": 8080}]
}' | jq '.Id'
# Start the container
curl -s --unix-socket /tmp/podman.sock -X POST http://d/v4.0.0/libpod/containers/my-nginx/start
5. Pods (Like Kubernetes)
# Create a pod
podman pod create --name my-app-pod -p 8080:80
# Add containers to pod
podman run -d --pod my-app-pod --name web nginx
podman run -d --pod my-app-pod --name api python:3.11-slim python3 -m http.server 8000
# List pods
podman pod list
# Generate Kubernetes YAML from pod!
podman generate kube my-app-pod > pod.yaml
6. Generate systemd Service
# Auto-create systemd service file
podman generate systemd --new --name my-nginx > ~/.config/systemd/user/my-nginx.service
systemctl --user enable --now my-nginx
Python Example
import requests_unixsocket
import json
session = requests_unixsocket.Session()
SOCK = "http+unix://%2Ftmp%2Fpodman.sock"
# List containers
containers = session.get(f"{SOCK}/v4.0.0/libpod/containers/json").json()
for c in containers:
print(f"Container: {c['Names'][0]} | State: {c['State']} | Image: {c['Image'][:40]}")
# List images
images = session.get(f"{SOCK}/v4.0.0/libpod/images/json").json()
for img in images:
names = img.get('Names', ['unnamed'])
print(f"Image: {names[0]} | Size: {img['Size']/(1024*1024):.0f}MB")
# List pods
pods = session.get(f"{SOCK}/v4.0.0/libpod/pods/json").json()
for p in pods:
print(f"Pod: {p['Name']} | Status: {p['Status']} | Containers: {len(p['Containers'])}")
Key Endpoints
| Endpoint | Description |
|---|---|
| /libpod/containers/json | List containers |
| /libpod/containers/create | Create container |
| /libpod/containers/{id}/start | Start container |
| /libpod/containers/{id}/stop | Stop container |
| /libpod/containers/{id}/logs | Get logs |
| /libpod/images/json | List images |
| /libpod/pods/json | List pods |
| /libpod/pods/create | Create pod |
| /libpod/info | System info |
Need custom data extraction or scraping solution? I build production-grade scrapers for any website. Email: Spinov001@gmail.com | My Apify Actors
Top comments (0)