Ray's Knowledge Base
Unlock

Run the dftracer-gcc12 container as the host user, not root

PitfallVerified 5 Oct 2026Holds project: dftracer-utils
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

Two tests set a file to mode 000 and expect a read error, but they fail only in the container.

Cause#

Root reads the file anyway.

Fix#

Fix the container invocation, not the tests: docker run --rm --user "$(id -u):$(id -g)" -e HOME=/tmp -v "$PWD":/work -w /work/build/build-docker-gcc12 dftracer-gcc12 .... HOME=/tmp is needed because the non-root user has no home directory. Permission-denied tests then pass as they do outside Docker.

Evidence#

Seen with docker-test-gcc12 runs on 2026-10-05.

Also found by searching

  • permission-denied test passes outside Docker but fails in the container
  • test sets file mode 000 and expects a read error but root reads it
  • docker run as host user with HOME=/tmp
  • dftracer-gcc12 container run command