Skip to content

Rootless Podman

Sam Bent edited this page Nov 17, 2026 · 6 revisions

Rootless Podman

Rootless Podman is the strongest isolation HiddenForge supports, and the project recommends it for high-risk deployments. In rootless mode, container uid 0 maps to your regular host user through Linux user namespaces. A container escape then gives an attacker your user account and not real root.

Use podman-compose.yml from the repository, not docker-compose.yml. It carries the same hardening, with the differences explained below.

The recommended path

Run Docker Compose v2 against the rootless Podman socket. It is the only way measured to apply every limit in podman-compose.yml. It needs only the Compose binary and not the Docker engine.

# Prerequisites (Ubuntu 24.04 shown). --no-install-recommends matters: without
# it apt also installs and starts the Docker engine, a root daemon.
sudo apt install podman
sudo apt install --no-install-recommends docker-compose-v2
systemctl --user enable --now podman.socket
# Come back after a reboot: Podman restarts only `restart: always` containers
# (the Podman file sets it), and only with these two enabled for your user.
loginctl enable-linger $USER
systemctl --user enable podman-restart.service
export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/podman/podman.sock
COMPOSE=/usr/libexec/docker/cli-plugins/docker-compose

mkdir -p ./tor-keys
$COMPOSE -p hiddenforge -f podman-compose.yml up -d

# Read the .onion address once Tor bootstraps (usually under a minute, up to ~6 on a slow connection)
$COMPOSE -p hiddenforge -f podman-compose.yml exec tor hiddenforge show --name myapp

Confirm the setup is rootless:

podman info --format '{{.Host.Security.Rootless}}'
# Expected output: true

Measured on stock Ubuntu 24.04 (Podman 4.9.3, docker-compose-v2 2.40.3, no Docker engine): the service reached ready, pids.max was 256, memory.swap.max was 0, and DNS was isolated. With Tor killed, the container restarted with the same address and served HTTP 200 over Tor. After a real reboot it came back ready with the same address.

Surviving a reboot

Requirement Why
restart: always in the compose file Podman's boot service starts only always containers. The shipped Podman file sets it.
loginctl enable-linger $USER Lets your user services run with no login session.
systemctl --user enable podman-restart.service The unit that runs podman start --all --filter restart-policy=always at boot.

The reason for always is a measured failure. On Ubuntu 24.04 with real reboots, the same stack with restart: unless-stopped left both containers stopped. With always it came back ready on the same address. The Docker file keeps unless-stopped, and three real reboots on Docker each came back by themselves.

Reading the address

$COMPOSE -p hiddenforge -f podman-compose.yml exec tor hiddenforge show --name myapp

The Podman file drops DAC_OVERRIDE, so the root user that exec gives you cannot traverse the 0700 tor-owned data directory. hiddenforge show, hiddenforge doctor and hiddenforge healthcheck switch to the tor user for the read by themselves. If you hit "Permission denied", do not add DAC_OVERRIDE back and do not loosen the key directory.

The key directory belongs to a subuid inside the user namespace, so the host cannot read it directly. Tor writes hostname as tor with mode 0600, and the supervisor reads it as the tor user and writes <name>.onion into your key volume. That file is world-readable, so hiddenforge show --keys ./tor-keys --name myapp works from the host once the address is published. Until then show exits 4:

$ hiddenforge show --keys ./tor-keys --name myapp --json
{"error": "address not published yet: tor-keys/myapp exists but is not readable
 by this user, and tor-keys/myapp.onion does not exist. ...", "exit_code": 4,
 "onion": null, ...}

hiddenforge show --container tor asks the container for the address as the tor user, which also works while the file does not exist yet.

Three capabilities, not five

Capability Docker (rootful) Podman (rootless)
DAC_OVERRIDE Required. ./tor-keys is owned by host uid 1000 and container root is a different user. Not needed. Inside the user namespace, container root is host uid 1000 and already owns the mount.
FOWNER Required. Container root cannot chmod files it does not own. Not needed, same reasoning.
CHOWN Required Required
SETUID / SETGID Required Required

podman-compose.yml therefore lists CHOWN, SETUID and SETGID after cap_drop: ALL. (hiddenforge setup --runtime podman still emits all five, because it cannot tell a rootless engine from a rootful one; on rootless Podman you may drop the two extra.) hiddenforge doctor knows the difference: on a rootless engine it requires those three, and on rootful Docker it requires all five.

No-root mode

hiddenforge setup --runtime podman --no-root writes a fragment that starts the container as the tor user (100:101) with no capabilities at all. deploy.sh runs podman unshare chown -R 100:101 on the key directory once, because nothing inside the container may chown. hiddenforge doctor recognises the mode and requires no capabilities. Back up such a key directory the same way, with podman unshare hiddenforge backup.

No healthcheck

The Podman file declares no healthcheck: key at all, not even disable: true.

Rootless Podman 4.9 runs healthchecks through systemd user timers. When no systemd user manager is reachable (a service account nobody logs into, sudo -iu, cron, a broken user bus), it never restarts a container that has a healthcheck. Measured on Ubuntu 24.04: with a healthcheck, the container stayed stopped after it exited. Without one, it restarted every time.

This container heals by exiting and being restarted: after Tor dies, when a backend moves to a new IP, and when a backend that was down at boot comes up. A restart that never happens is an outage. disable: true does not help, because Docker Compose sends it to Podman as test [NONE], which Podman 4.9 still treats as a healthcheck (measured: not restarted).

Readiness comes from hiddenforge status, which runs the same check itself when the engine reports no health.

What podman-compose silently drops

If you use podman-compose instead of Docker Compose (pip install podman-compose), two declared limits are not applied:

Setting podman-compose behaviour Result
pids_limit: 256 Honoured only from podman-compose 1.1. Ubuntu 24.04 ships 1.0.6. Podman's default of 2048 processes
memswap_limit: 512m Honoured by no version The container may use swap

Workarounds: bring the stack up with --podman-run-args="--pids-limit=256" (it applies to every service in the file, your backend included), and for swap, run the host with none. Docker Compose on the Podman socket applies both, which is why it is the recommended path.

podman-compose -f podman-compose.yml up -d
podman-compose -f podman-compose.yml exec tor hiddenforge show --name myapp

Other differences from the Docker file

  • No explicit apparmor= option. Rootless Podman often cannot load the docker-default profile, so it applies its own.
  • The engine's default seccomp profile applies under Tor's own sandbox, as on Docker. Do not add seccomp=unconfined.
  • tmpfs entries carry no uid=, gid= or mode= options, because Podman does not support them. The entrypoint chowns /var/lib/tor at startup.
  • dns: 127.0.0.1 stops an unanswered backend name from going to your host's resolver. Podman's aardvark-dns would otherwise forward it.
  • A backend on port 80 or 443 needs NET_BIND_SERVICE under rootless Podman, or a port of 1024 or above (for example "80:web:8080").

What hiddenforge doctor checks

hiddenforge doctor --container tor --keys ./tor-keys --json
Check Severity
CHOWN, SETUID and SETGID are present, and nothing outside the allowed five fail
A runtime seccomp profile is applied (not unconfined) fail
Process count capped at 512 or fewer (fails under old podman-compose, and says why) fail
Swap disabled, measured from memory.swap.max fail, or warn if the host has no swap
Restart policy set (always required for a reboot under Podman) fail if none, warn if not always
Linger enabled warn
podman-restart.service enabled warn
dns: set to a loopback address warn

These are measured inside the running container where possible, so the result reflects what was applied and not what the compose file asked for. For the full list, and for the systemd-unit case, see The hiddenforge CLI.

Clone this wiki locally