Skip to content

fix(docker): install binaries outside /root so the image runs as non-root - #599

Open
sebastianst wants to merge 1 commit into
flashbots:mainfrom
sebastianst:seb/non-root-container
Open

sebastianst wants to merge 1 commit into
flashbots:mainfrom
sebastianst:seb/non-root-container

Conversation

@sebastianst

Copy link
Copy Markdown

Motivation

The image installs contender and anvil into /root/.cargo/bin, and /root is mode 0700. So the image can't run as any user other than root:

$ docker run --rm --user 1000:1000 flashbots/contender --version
docker: Error response from daemon: ... exec: "contender": executable file not found in $PATH

Containers therefore have to run as root, and on Linux every file contender writes into a mounted data dir comes out root-owned on the host. We hit this in Kupcake, which runs every other service as the host user.

Solution

  • Install the binaries into /usr/local/bin and drop the PATH override.
  • Drop mkdir -p /root/.contender. That's the legacy data dir, and creating it only triggers the migration to ~/.local/state/contender. The comment now points at the current data dir.
  • Add a README example for running as the host user with CONTENDER_DATA_DIR.

The default user stays root, so the documented -v …:/root/.local/state/contender mount keeps working.

Tested on a locally built image, running as --user $(id -u):$(id -g) --cap-drop ALL: anvil, contender spam … transfers and contender report all ran, and every file in the data dir was owned by the host user.

PR Checklist

  • Added Tests: n/a, Dockerfile only
  • Added Documentation
  • Ran cargo +nightly clippy …: n/a, no Rust changes
  • Ran cargo fmt --all: n/a
  • Note breaking changes in PR description, if applicable: none, unless something calls /root/.cargo/bin/contender by its full path
  • update changelogs: none of the crate changelogs cover the image

🤖 Co-created with Claude Opus 5.5

…root

The runtime image copied `contender` and `anvil` into `/root/.cargo/bin`.
`/root` is mode 0700, so `docker run --user <uid>:<gid>` failed with
`exec: "contender": executable file not found in $PATH`, which forced
containers to run as root and left root-owned files in mounted data dirs.

Install them into `/usr/local/bin`, drop the PATH override, and drop the
`/root/.contender` mkdir: that is the legacy data dir, and creating it only
triggers the migration to `~/.local/state/contender`. Document running as the
host user. The default user stays root, so existing mounts keep working.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant