Skip to content

fix(docker): prevent root-owned bind mount directories - #160

Open
Kubuxu wants to merge 1 commit into
mainfrom
fix/volume-ownership
Open

fix(docker): prevent root-owned bind mount directories#160
Kubuxu wants to merge 1 commit into
mainfrom
fix/volume-ownership

Conversation

@Kubuxu

@Kubuxu Kubuxu commented Jul 30, 2026

Copy link
Copy Markdown

Pre-create and validate bind mount sources before invoking Docker so Docker cannot silently create missing host directories as root.

Replace legacy -v bind syntax with explicit --mount specifications, remove unnecessary runtime Cargo mounts, and support writable and read-only bind mounts through a shared helper.

This prevents builder cache ownership failures that block Lotus builds and leave required binaries such as lotus-seed unavailable.

Signed-off-by: Jakub Sztandera [email protected]

Pre-create and validate bind mount sources before invoking Docker so Docker cannot silently create missing host directories as root.

Replace legacy -v bind syntax with explicit --mount specifications, remove unnecessary runtime Cargo mounts, and support writable and read-only bind mounts through a shared helper.

This prevents builder cache ownership failures that block Lotus builds and leave required binaries such as lotus-seed unavailable.

Signed-off-by: Jakub Sztandera <[email protected]>
Copilot AI review requested due to automatic review settings July 30, 2026 13:35
@FilOzzy FilOzzy added this to FOC Jul 30, 2026
@github-project-automation github-project-automation Bot moved this to 📌 Triage in FOC Jul 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Not ready to approve

The new mounts helper currently treats read-only mounts like writable ones (creating and write-testing sources), and build container setup can silently create a missing source directory instead of failing fast.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

This PR hardens Docker invocations across foc-devnet by switching from -v bind syntax to explicit --mount specifications and adding a shared helper that prepares/validates bind sources to prevent Docker from auto-creating host directories as root (which can break subsequent builds via ownership mismatches).

Changes:

  • Introduces src/docker/mounts.rs helpers to pre-create and validate bind mount sources and to build/push --mount arguments (including read-only).
  • Replaces many -v usages with --mount (and shared helpers) across startup/deploy/build codepaths.
  • Removes some legacy runtime cache mounts (e.g., Cargo) while keeping mount handling consistent.
File summaries
File Description
src/docker/shell.rs Renames the helper to run containers using prepared --mount specs.
src/docker/portainer.rs Uses --mount for docker socket bind and Portainer data volume.
src/docker/mounts.rs Adds bind mount preparation/validation and --mount argument builders (plus tests).
src/docker/mod.rs Exposes the new mounts helpers via pub use.
src/commands/start/usdfc_funding/funding_operations.rs Switches USDFC funding operations to use --mount with validated bind sources.
src/commands/start/usdfc_deploy/verification.rs Uses validated bind mounts for contract verification runs.
src/commands/start/usdfc_deploy/foundry_setup.rs Uses validated bind mounts for Foundry project setup.
src/commands/start/usdfc_deploy/deployment.rs Uses validated bind mounts for Foundry deployment.
src/commands/start/multicall3_deploy/deployment.rs Builds docker args as Vec<String> and appends validated bind mounts.
src/commands/start/mod.rs Updates regenesis fallback Docker deletion to --mount.
src/commands/start/lotus/setup.rs Replaces volume list -v usage with validated bind mounts.
src/commands/start/lotus_miner/docker_command.rs Replaces -v usage with validated bind mounts and removes builder Cargo mount.
src/commands/start/genesis/sectors.rs Uses validated bind mounts for preseal workflow and removes builder Cargo mount.
src/commands/start/genesis/proof_parameters.rs Uses validated bind mounts for proof-params download and removes builder Cargo mount.
src/commands/start/genesis/construction/signers.rs Uses validated bind mounts and removes builder Cargo mount.
src/commands/start/genesis/construction/miner.rs Uses validated bind mounts and removes builder Cargo mount.
src/commands/start/genesis/construction/creation.rs Uses validated bind mounts and removes builder Cargo mount.
src/commands/start/foc_deployer/mod.rs Uses validated bind mounts and removes builder Cargo mount; updates optional pdp repo mount.
src/commands/start/curio/verification.rs Uses validated bind mounts for test-data and bin mounts.
src/commands/start/curio/db_setup.rs Uses validated bind mounts for lotus bins and lotus data access.
src/commands/start/curio/daemon.rs Replaces volume mount list with validated bind mounts including a read-only mount.
src/commands/build/docker.rs Uses validated bind mounts for build source/output and mapped volumes.
Review details
  • Files reviewed: 22/22 changed files
  • Comments generated: 2
  • Review effort level: Low

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

Comment thread src/docker/mounts.rs
Comment on lines +72 to +85
fn bind_mount_with_mode(
source: &Path,
target: &str,
read_only: bool,
) -> Result<String, Box<dyn Error>> {
prepare_bind_source(source)?;
let read_only_option = if read_only { ",readonly" } else { "" };
Ok(format!(
"type=bind,source={},target={}{}",
source.display(),
target,
read_only_option
))
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read-only is mostly focused on in-container scope. IDK if it is worth addressing.

Comment on lines +94 to +103
push_bind_mount(
&mut docker_run_args,
Path::new(source_dir),
container_source_dir,
)?;
push_bind_mount(
&mut docker_run_args,
Path::new(output_dir),
container_output_dir,
)?;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point of this is to create these directories in general. Yes, we could special case source directories but that is nitpicking.

@Kubuxu Kubuxu self-assigned this Jul 30, 2026
@rjan90
rjan90 self-requested a review July 30, 2026 15:16
@rjan90 rjan90 moved this from 📌 Triage to 🔎 Awaiting review in FOC Jul 30, 2026

@rvagg rvagg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, ok, sgtm

@github-project-automation github-project-automation Bot moved this from 🔎 Awaiting review to ✔️ Approved by reviewer in FOC Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✔️ Approved by reviewer

Development

Successfully merging this pull request may close these issues.

5 participants