Run the container as a fixed non-root uid #47
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Current state
The image sets no
USER, so ER runs as root (uid 0, gid 0), verified on the v2.0.0 candidate:This is unchanged by the Alpine/musl switch — the Debian image ran as root too. Raised by Roku via Axianthe while preparing the Kyoshi deployment.
Why it should change
ER has no need for uid 0 at runtime. Inside the container it binds
HTTP_PORT(default 80) and 443, and privileged ports only matter because the image defaults to them — a non-root ER can bind 8080/8443 inside the container and be published on 80/443 by the runtime, which is how Roku's deployment is shaped anyway.Against that, running as root means a container escape starts as root, and the unencrypted certificate store's protection is now entirely file-mode based, so the uid that owns it matters more than it used to.
Why not in v2.0.0
A uid change is a breaking change to every existing deployment's data volume, and v2.0.0 already carries the TPM/OpenBao removal and the per-name certificate migration. Bundling a third thing that fails at first start — rather than at build or config time — is how a release becomes un-rollbackable. Axianthe's call, and I agree.
Host-side changes a consumer must make first
Whatever uid is chosen, every bind-mounted or named-volume path ER writes has to be owned by it before the first start, because ER will not create or chown what it cannot write:
/app/data, holds the SQLite database, its-wal/-shmsidecars, every certificate and key, and the ACME account key) —chown -R <uid>:<gid>. ER setsumask(077)before opening the database and corrects the main file's mode, but it cannot fix ownership; a foreign owner is a deliberate hard error.*_FILEsecret —HTTPREQ_USERNAME_FILE,HTTPREQ_PASSWORD_FILE,MASTER_API_KEY_FILE. ER reads these without inspecting mode or owner (see79a7171), so a root-owned 0400 secret becomes unreadable the moment ER is not root. Roku's is exactly this: root-owned 0400. Either re-own it to the new uid or set the Compose secret'suid/mode.[[static_sites]]directories — read access for the new uid./dev/logor journal socket, if a deployment wires one.Decisions to make
chowns/app/dataat build time (helps a fresh named volume, does nothing for an existing one or a bind mount).For v2.0.0
Nothing to do in the code. The release notes must state the image's
USERand uid explicitly — currently root/0 — so Roku and anyone else can prepare the host. Tracked here so that statement is a documented current state rather than an omission.