{"data":{"slug":"discovered-18e13a604eaf33822fdfe9a8ae7231699bc1f7c60b6e89e6","title":"Podman Patterns for Local Testing and Linux Integration","summary":"Use Podman on macOS for local tests, including installing Podman, running a Podman machine, and using a throwaway database container. On Linux, use Quadlet, play kube, and compose for production services. This skill supports running containerized apps, even when no database is present, and ensures rootless operation by default.","url":"https:\/\/skillshunter.net\/skills\/discovered-18e13a604eaf33822fdfe9a8ae7231699bc1f7c60b6e89e6","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/discovered-18e13a604eaf33822fdfe9a8ae7231699bc1f7c60b6e89e6","markdown_url":"https:\/\/skillshunter.net\/skills\/discovered-18e13a604eaf33822fdfe9a8ae7231699bc1f7c60b6e89e6.md","download_url":"https:\/\/skillshunter.net\/skills\/discovered-18e13a604eaf33822fdfe9a8ae7231699bc1f7c60b6e89e6\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Install Podman via `.pkg` from podman.io or Homebrew. Run `podman machine init --now` to create and start the default machine. Use `podman compose up -d --wait` from an existing compose file. Avoid switching the machine to rootful for tests. Keep the repo's `compose.yaml` or `docker-compose.yml` and run with `podman compose`.","instructions":"---\nname: podman-patterns\nversion: 1.1.0\ndescription: \"Podman on macOS for local tests: install, podman machine, a throwaway database container, and a pod for the app even when the test has no database. Also Quadlet, play kube, and compose on Linux. Use when a php\/node\/python test needs MariaDB, Postgres, Redis, or the same image CI runs.\"\n---\n\n# Podman Patterns (2026)\n\n**Invoke when a local test needs a database or a containerized app, when installing Podman on a Mac, or when writing Quadlet \/ play-kube definitions on Linux.**\n\n> 2026 reality: **Rootless is the default**. No container runtime should run as root. Podman + Quadlet is the recommended path on Linux for production services. `podman play kube` replaces simple `kubectl apply` for single-pod workloads. Dockerfiles are fully compatible.\n\n## Why Podman in 2026\n\n| Aspect | Docker | Podman | Winner |\n|--------|--------|--------|--------|\n| Daemon | Required (root) | None | Podman |\n| Root | Required for daemon | Rootless by default | Podman |\n| Kubernetes | Separate (kind\/minikube) | `podman play kube` | Podman |\n| Systemd | Manual units | Quadlet (native) | Podman |\n| macOS\/Windows | Docker Desktop | `podman machine` + a local pod | Podman for local tests |\n| CI | Docker-in-Docker | Native rootless | Podman |\n\n**Rule:** On a Mac, local tests run in the Podman machine (\u00a75). On a Linux server or in CI, prefer Podman. Compose files stay as they are and run with `podman compose`.\n\n---\n\n## 1. Rootless + Distroless (Node.js example)\n\n```dockerfile\n# syntax=docker\/dockerfile:1.7\nARG NODE_VERSION=22.11.0\n\nFROM node:${NODE_VERSION}-alpine AS builder\nWORKDIR \/app\nCOPY package*.json .\/\nRUN --mount=type=cache,target=\/root\/.npm \\\n    npm ci --ignore-scripts\nCOPY . .\nRUN npm run build && npm prune --omit=dev\n\nFROM gcr.io\/distroless\/nodejs22-debian12:nonroot\nWORKDIR \/app\nCOPY --from=builder --chown=nonroot:nonroot \/app\/node_modules .\/node_modules\nCOPY --from=builder --chown=nonroot:nonroot \/app\/dist         .\/dist\nCOPY --from=builder --chown=nonroot:nonroot \/app\/package.json .\/\nUSER nonroot\nEXPOSE 3000\nENV NODE_ENV=production\nHEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \\\n  CMD [\"\/nodejs\/bin\/node\", \"-e\", \"fetch('http:\/\/127.0.0.1:3000\/healthz').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))\"]\nCMD [\"dist\/server.js\"]\n```\n\nRun rootless:\n\n```bash\npodman run -d --name app \\\n  --user 10001:10001 \\\n  --read-only \\\n  --security-opt no-new-privileges \\\n  -p 3000:3000 \\\n  localhost\/myapp:latest\n```\n\n---\n\n## 2. Quadlet \u2014 The 2026 Way to Run Containers as Services\n\nInstead of writing systemd units by hand, use **Quadlet** (`.container` files).\n\n### Example: `myapp.container`\n\n```ini\n[Unit]\nDescription=My Node.js App\nAfter=network-online.target\nWants=network-online.target\n\n[Container]\nImage=localhost\/myapp:latest\nContainerName=myapp\nPublishPort=3000:3000\nEnvironment=NODE_ENV=production\nHealthCmd=\/nodejs\/bin\/node -e \"fetch('http:\/\/127.0.0.1:3000\/healthz').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))\"\nHealthInterval=30s\nHealthTimeout=3s\nHealthStartPeriod=5s\nHealthRetries=3\nReadOnly=true\nUser=10001\nGroup=10001\nSecurityLabelDisable=false\n\n[Service]\nRestart=always\nRestartSec=5\n\n[Install]\nWantedBy=multi-user.target\n```\n\nInstall:\n\n```bash\nsudo cp myapp.container \/etc\/containers\/systemd\/\nsudo systemctl daemon-reload\nsudo systemctl start myapp.service\n```\n\nQuadlet automatically creates the proper systemd service, handles restarts, and integrates with `podman`.\n\n---\n\n## 3. `podman play kube` \u2014 Single-Pod Kubernetes\n\nFor simple workloads, avoid full Kubernetes. Use a Pod manifest:\n\n```yaml\napiVersion: v1\nkind: Pod\nmetadata:\n  name: myapp\n  labels:\n    app: myapp\nspec:\n  containers:\n  - name: app\n    image: localhost\/myapp:latest\n    ports:\n    - containerPort: 3000\n    env:\n    - name: NODE_ENV\n      value: production\n    securityContext:\n      runAsNonRoot: true\n      runAsUser: 10001\n      readOnlyRootFilesystem: true\n    livenessProbe:\n      exec:\n        command:\n        - \/nodejs\/bin\/node\n        - -e\n        - \"fetch('http:\/\/127.0.0.1:3000\/healthz').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))\"\n      initialDelaySeconds: 5\n      periodSeconds: 30\n  restartPolicy: Always\n```\n\nDeploy:\n\n```bash\npodman play kube myapp.yaml\n```\n\nStop:\n\n```bash\npodman play kube --down myapp.yaml\n```\n\nThis is dramatically simpler than Helm or full K8s for single-service apps.\n\n---\n\n## 4. Secrets (Better Than Docker Build Secrets)\n\nPodman supports `--secret` natively:\n\n```bash\npodman run --secret id=stripe_key,src=.env.d\/local\/secrets\/stripe.key \\\n  -e STRIPE_SECRET_KEY_FILE=\/run\/secrets\/stripe_key \\\n  localhost\/myapp\n```\n\nInside the container, the secret is available at `\/run\/secrets\/stripe_key` and is never stored in the image layer.\n\nSee `secrets-management` for the full `.env.d\/` + secret file pattern.\n\n---\n\n## 5. macOS \u2014 install, then test in a pod\n\nContainers are Linux. On a Mac the CLI talks to a Linux VM called a Podman machine. That machine is the local runtime. A **pod** is the unit that runs the app, with a database container beside it only when the test needs one.\n\nQuadlet and `systemctl` belong on the Linux server. Do not copy `.container` files onto the Mac.\n\n### Install\n\nPodman documents the `.pkg` from [podman.io](https:\/\/podman.io\/docs\/installation) as the stable Mac install. When Homebrew is already the machine's package manager:\n\n```bash\nbrew install podman\npodman machine init --now\npodman info\npodman run --rm quay.io\/podman\/hello\n```\n\n`podman machine init --now` creates `podman-machine-default` and starts it. The default connection is **rootless**. Do not switch the machine to rootful for a test.\n\nIf the machine already exists and `podman info` says the service is down:\n\n```bash\npodman machine start\n```\n\n`podman compose` is a wrapper. If it reports a missing provider:\n\n```bash\nbrew install docker-compose\n```\n\nThat installs Compose v2. It does not install Docker Desktop. Keep the repo's `compose.yaml` \/ `docker-compose.yml` and run it with `podman compose`.\n\nBind mounts work for a repo under `\/Users`. A path outside the home directory is not shared into the VM.\n\n### When the pod is the test target\n\n| Situation | What to run |\n|---|---|\n| Repo already has a compose file | `podman compose up -d --wait` from that file. Do not invent a second compose. |\n| Test needs MariaDB, Postgres, Redis, or Mongo and nothing is listening on `127.0.0.1` | One throwaway database container, published only on `127.0.0.1`. |\n| No database (sqlite, in-memory, or a pure API) | Still run the **app** container or pod. The test hits the same image CI runs. |\n\nDo not `brew install mariadb` \/ `postgresql` \/ `redis` on the Mac to unblock a test. The container is the database.\n\n### Database container\n\nPassword stays in this shell. Do not write it into the repo `.env` and do not print it.\n\n```bash\nexport MARIADB_ROOT_PASSWORD=\"$(openssl rand -base64 24)\"\npodman run -d --name svs-test-db --replace \\\n  -p 127.0.0.1:3306:3306 \\\n  -e MARIADB_ROOT_PASSWORD \\\n  -e MARIADB_DATABASE=app_test \\\n  docker.io\/library\/mariadb:11.8\npodman wait --condition=healthy svs-test-db\n```\n\nPostgres is the same shape: `docker.io\/library\/postgres:17`, port `127.0.0.1:5432`, `POSTGRES_PASSWORD` and `POSTGRES_DB=app_test`. Redis: `docker.io\/library\/redis:7`, port `127.0.0.1:6379`, no password on this loopback port. Point the test process at `127.0.0.1` and the published port. Apple Silicon pulls the arm64 image. Add `--platform linux\/amd64` only when that image has no arm64 build.\n\n### App pod, with or without a database\n\n```bash\npodman pod create --name svs-test --replace \\\n  -p 127.0.0.1:8080:8080\npodman run -d --pod svs-test --name svs-test-app \\\n  -e APP_ENV=testing \\\n  localhost\/myapp:latest\n```\n\nContainers in one pod share `localhost`, so an app container can use `127.0.0.1:3306` for a database container started in the same pod. Publish the app port to the Mac with `127.0.0.1` so the Playwright walk and the test runner reach it. Do not publish `0.0.0.0`.\n\nWhen the repo compose file already declares the app and its database, prefer that file:\n\n```bash\npodman compose up -d --wait\n```\n\n### Tear down\n\nRemove the test pod and the database container when the task is done, unless the same session still needs them. A named volume keeps the last schema; drop it when the next run must start empty.\n\n```bash\npodman pod rm -f svs-test\npodman rm -f svs-test-db\npodman volume rm svs-test-db\n```\n\n`podman machine stop` stops every container on the Mac. Use it when the user asks to shut the VM down, not after each test.\n\n---\n\n## 6. Migration from Docker\n\n| Docker Command | Podman Equivalent | Notes |\n|----------------|-------------------|-------|\n| `docker build` | `podman build` | Same syntax |\n| `docker compose up` | `podman compose up` | Full compatibility |\n| `docker run --user` | `podman run --user` | Rootless is default |\n| Manual systemd unit | Quadlet `.container` | Much simpler |\n| `docker ps` | `podman ps` | Identical output |\n| `docker system prune` | `podman system prune` | Same |\n\n**Rule:** Keep using `docker-compose.yml` if you want \u2014 just run it with `podman compose`. The compose file is unchanged.\n\n---\n\n## 7. Integration With Other Skills\n\n- `secrets-management` \u2014 Use `.env.d\/` + `--secret` mounts.\n- `security-baseline` \u2014 Rootless + read-only + no-new-privileges is the baseline.\n- `ci-pipelines` \u2014 Run `podman` instead of `docker` in GitHub Actions (no DinD needed).\n- `docker-patterns` \u2014 Podman can consume the exact same Dockerfiles. The two skills are complementary.\n\n---\n\n## FORBIDDEN\n\n| Pattern | Reason |\n|---------|--------|\n| Running Podman as root | Defeats the entire security model |\n| Using `sudo podman` in scripts | Indicates misconfiguration |\n| Storing secrets in image layers | Use `--secret` or mounted files |\n| Running containers with `--privileged` | Never needed with rootless + proper capabilities |\n| Ignoring healthchecks | Quadlet and `podman play kube` both support them natively |\n| `podman machine set --rootful` for a local test | The default machine is rootless |\n| Publishing a test database on `0.0.0.0` | Bind `127.0.0.1` only |\n| Quadlet or `systemctl` on the Mac | The Mac uses the machine and a pod. Quadlet is the Linux server |\n| `brew install` of MariaDB, Postgres, or Redis to unblock a test | Run that engine in a container |\n\n---\n\n## Pre-Deployment Checklist\n\n- [ ] Image built with multi-stage + distroless\/chiseled\n- [ ] Non-root user (10001:10001 or higher)\n- [ ] Read-only root filesystem\n- [ ] Healthcheck defined\n- [ ] Secrets passed via `--secret` (not ENV or COPY)\n- [ ] On a Mac \u2192 `podman machine` is up, test ports bound to `127.0.0.1`, pod removed when the task ends\n- [ ] If Linux server \u2192 Quadlet `.container` file\n- [ ] If simple K8s workload \u2192 `podman play kube` manifest\n- [ ] `.dockerignore` present (same as Docker)\n\n---\n\n## See Also\n\n- `docker-patterns` \u2014 the Docker side of the same story (compatible)\n- `secrets-management` \u2014 how to structure `.env.d\/` and secret files\n- `security-baseline` \u2014 rootless is now table stakes\n- `ci-pipelines` \u2014 rootless CI runners\n\n---\n\n## Memory Optimization Trigger\n\nIf this skill grows beyond ~250 lines or accumulates many near-duplicate Quadlet examples, run:\n\n```bash\nnpx start-vibing-stacks memory optimize --dry-run\n```","use_cases":["Install and configure Podman on macOS for local development","Run a containerized app with a throwaway database container","Use Quadlet and `systemctl` on Linux for production services","Use `podman play kube` for single-pod workloads on Linux","Run a rootless container on macOS or Linux"],"limitations":[],"compatibility":[],"setup_tip":"Podman documents the `.pkg` from [podman.io](https:\/\/podman.io\/docs\/installation) as the stable Mac install. When Homebrew is already the machine's package manager:\n\n```bash\nbrew install podman\npodman machine init --now\npodman info\npodman run --rm quay.io\/podman\/hello\n```\n\n`podman machine init --now` creates `podman-machine-default` and starts it. The default connection is **rootless**. Do not switch the machine to rootful for a test.\n\nIf the machine already exists and `podman info` says the service is down:\n\n```bash\npodman machine start\n```\n\n`podman compose` is a wrapper. If it reports a missing provider:\n\n```bash\nbrew install docker-compose\n```\n\nThat installs Compose v2. It does not install Docker Desktop. Keep the repo's `compose.yaml` \/ `docker-compose.yml` and run it with `podman compose`.\n\nBind mounts work for a repo under `\/Users`. A path outside the home directory is not shared into the VM.","sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/0x57-1\/start-vibing-stacks\/blob\/6e398b34c4dfe73ac8f809216b218856b8e02ff4\/stacks\/_shared\/skills\/podman-patterns\/SKILL.md","source_commit":"6e398b34c4dfe73ac8f809216b218856b8e02ff4","license":null,"version":null,"listing_approved_at":"2026-12-03","created_at":"2026-12-02T09:11:38.000000Z","updated_at":"2026-12-03T16:20:08.000000Z","seo_title":"Podman Patterns for Local Testing and Linux Integration","seo_description":"Learn how to use Podman on macOS for local tests, including installing Podman, running a Podman machine, and using a throwaway database container. On Linux, use Quadlet,`","seo_keywords":["Podman","Podman machine","Podman on macOS","Podman for local tests","Quadlet","podman play kube","rootless containers","containerized app testing"]}}