Skip to content

[Docker] Make non-root image volume mount points writable by the isaaclab user (cherry-pick #6082 → 3.0.0-beta2) - #6095

Merged
hujc7 merged 3 commits into
isaac-sim:release/3.0.0-beta2from
hujc7:jichuanh/cherrypick-6082-release-3.0.0-beta2
Jun 10, 2026
Merged

hujc7 merged 3 commits into
isaac-sim:release/3.0.0-beta2from
hujc7:jichuanh/cherrypick-6082-release-3.0.0-beta2

Conversation

@hujc7

@hujc7 hujc7 commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Cherry-pick of [Docker] Make non-root image volume mount points writable by the isaaclab user #6082 onto release/3.0.0-beta2. Net diff is identical to the develop-side PR; applies cleanly with no conflicts.
  • Fixes training regressions in the non-root Docker images (base + cuRobo): skrl training aborts with PermissionError creating logs/, and Isaac Sim emits omni.datastore lock failures under kit/cache (tripping the CI training-log blacklist).
  • Root cause: a fresh Docker named volume inherits ownership from the image directory at its mount path; the non-root isaaclab user (uid/gid 1000) cannot write mount points the image left missing or root-owned.
  • Pre-creates and chowns every named-volume mount point before the USER switch, driven by a single source of truth — docker-compose.yaml, parsed by docker/utils/volume_mounts.py — so the list is never duplicated in the Dockerfiles.

1. Background

#5618 switched the base / ROS 2 / cuRobo images to USER isaaclab (uid/gid 1000) so bind-mounted workspaces stay writable for the host/runner user. That change covered the ${DOCKER_USER_HOME} mount points (swept by the recursive chown), but not the named volumes that mount outside the runtime home.

2. Mechanism

When an empty named volume is mounted for the first time, Docker (the root daemon) seeds the volume's ownership from the image directory at that path. If that directory is missing or root-owned in the image, the volume comes up root:root and the uid-1000 runtime user is denied. The home-based volumes already inherited the right owner; the ones under /isaac-sim and /workspace/isaaclab did not (kit/cache was created root-owned by a build mkdir; logs / data_storage / docs/_build did not exist in the image at all).

3. Fix

3.1 docker/utils/volume_mounts.py — parses the type: volume targets out of docker-compose.yaml (the single source of truth) and resolves the ${VAR} paths. Reuses PyYAML, already an IsaacLab dependency.

3.2 Dockerfile.base / Dockerfile.curobo — before USER isaaclab, invoke the parser and mkdir -p + chown -R isaaclab:isaaclab every mount point, so fresh volumes inherit isaaclab ownership. set -o pipefail plus a non-empty guard abort the build if the parse yields nothing, rather than silently shipping an unprepared mount point. The ROS 2 image builds FROM base and inherits the fix.

3.3 Adding a volume to docker-compose.yaml is now prepared automatically — no second list to keep in sync.

4. Test

docker/test/test_dockerfile_nonroot.py unit-tests the parser (asserting it returns the mount points that triggered the regression) and asserts each non-root Dockerfile wires the parser in with the guard. Static, no image build required.

5. Validation

  • Static tests pass (13 passed); the parser test fails if compose drops a tracked volume.
  • Verified on a freshly built base image: all named-volume mount points come up uid 1000, and the exact QA training (skrl Anymal-C) runs to completion with no PermissionError and zero omni.datastore lock failures.

6. Notes

  • No changelog fragment: docker/ is not under source/<pkg> (matches Make Isaac Lab Docker images run as non-root #5618).
  • cuRobo has no compose file today, but it creates kit/cache as root and runs Isaac Sim non-root, so its cache is unwritable even without a volume mount; the same step fixes it.

hujc7 added 3 commits June 10, 2026 04:34
The base and cuRobo images run as the non-root isaaclab user (uid/gid
1000). A fresh Docker named volume inherits ownership from the image
directory at its mount path on first mount; if that directory is missing
or root-owned, the volume comes up root-owned and the isaaclab user
cannot write it.

This broke training in the Docker images: skrl train.py aborted with
PermissionError creating logs/, and Isaac Sim emitted omni.datastore
lock failures under kit/cache (failing the CI log blacklist).

Pre-create every named-volume mount point that lives outside the runtime
home and chown it to isaaclab before the USER switch, so fresh volumes
inherit isaaclab ownership. Add a static test cross-checking the
docker-compose volume targets against the Dockerfile mkdir/chown coverage
so a newly added volume cannot regress this.
Replace the hardcoded per-Dockerfile list of mount-point directories with
a parse of docker-compose.yaml, the single source of truth for the named
volumes. docker/utils/volume_mounts.py reads the volume targets; the base
and cuRobo image builds invoke it to pre-create and chown each mount point
to the isaaclab user before the USER switch.

This removes the second list that had to be kept in sync with compose: a
volume added to compose is now prepared automatically, with no Dockerfile
edit. pipefail plus a non-empty guard abort the build if the parse yields
nothing, so a parse failure can never silently ship an unprepared mount
point.

The regression test now unit-tests the parser (covering the directories
that triggered the original failures) and asserts each non-root Dockerfile
wires the parser in with the guard, instead of policing a duplicated list.
- Guard the test's module loader against a None spec/loader so a wrong
  path gives a clear message instead of an opaque AttributeError.
- Drop the redundant `test -n "${dirs}"` from the Dockerfile prep step:
  under `set -o pipefail` the `dirs=$(... | grep '^/')` assignment already
  fails (grep exits non-zero on no matches) and short-circuits the chain,
  so the guard was unreachable. Reword the comment to credit pipefail and
  update the wiring test accordingly.

@isaaclab-review-bot isaaclab-review-bot Bot 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.

Automated Review: PR #6095

Cherry-pick of #6082 → release/3.0.0-beta2

This is a clean cherry-pick that fixes Docker non-root image volume mount writability issues. The implementation looks solid.

Summary

Aspect Assessment
Purpose Fix PermissionError and omni.datastore lock failures in non-root Docker images
Approach Single source of truth via volume_mounts.py parser + compose file
Files Changed 4 files, +190 lines
Test Coverage Comprehensive static tests added

Strengths

  1. Single Source of Truth: Using docker-compose.yaml as the canonical list of volume mounts and parsing it during build eliminates the risk of Dockerfiles drifting out of sync.

  2. Fail-Fast Design: The set -o pipefail combined with guards ensures build failures are loud and early rather than shipping images with unprepared mount points.

  3. Well-Documented: Both the code and PR description clearly explain the root cause (Docker volume ownership inheritance) and the fix mechanism.

  4. Test Coverage: The new tests in test_dockerfile_nonroot.py validate:

    • Parser returns expected mount points
    • Resolved paths are absolute
    • Dockerfiles properly wire the parser with guards

Observations

  1. docker/utils/volume_mounts.py:

    • Clean implementation using PyYAML (already an IsaacLab dependency)
    • Good error handling with explicit failure messages for unresolved variables or empty results
    • The _VOLUMES_KEY = "x-default-isaac-lab-volumes" relies on a compose extension field - ensure this key exists in the target branch's docker-compose.yaml
  2. Dockerfile Changes:

    • Both Dockerfile.base and Dockerfile.curobo have identical blocks - this is intentional since cuRobo doesn't inherit from base
    • The comment blocks are thorough and explain the "why" well
  3. Test Design:

    • Smart use of pytest.importorskip("yaml") to gracefully skip parser tests if PyYAML isn't available in test env
    • The _load_module helper handles the non-package nature of the docker/ directory

Minor Suggestions (Non-blocking)

  • Consider whether the volume_mounts.py parser could benefit from caching if called multiple times during a build (currently not an issue as it's called once)
  • The identical Dockerfile blocks could potentially be factored into a shared script, but the current approach is explicit and easy to audit

Conclusion

This is a well-engineered fix for a real regression in the non-root Docker workflow. The single-source-of-truth approach and fail-fast guards are exactly the right patterns for infrastructure code that must stay in sync.


This review was performed by an automated system. Please verify the technical details and ensure CI passes before merging.

@greptile-apps

greptile-apps Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This cherry-pick fixes permission errors in non-root Docker images by pre-creating every named-volume mount point and chowning it to the isaaclab user (uid 1000) before the USER switch, driven by a new docker/utils/volume_mounts.py parser that reads mount targets from docker-compose.yaml as the single source of truth.

  • docker/utils/volume_mounts.py: New parser reads type: volume entries from the x-default-isaac-lab-volumes extension field, expands ${VAR} references from the environment, and exits non-zero on an empty or unresolved list so the build fails loudly rather than shipping unprepared mount points.
  • Dockerfile.base / Dockerfile.curobo: Identical new RUN block (placed before USER isaaclab) exports the three path env vars, calls the parser via isaaclab.sh -p, filters output through grep '^/', then runs mkdir -p + chown -R; set -o pipefail ensures any parse or filter failure aborts the build.
  • docker/test/test_dockerfile_nonroot.py: Three new static tests validate the parser returns the regression-triggering volumes, that paths resolve to absolute values with the expected env, and that each non-root Dockerfile wires the parser in with the pipefail guard.

Confidence Score: 4/5

Safe to merge; the fix is well-contained to Docker build steps that run as root before the USER switch, with a loud build-time guard if the parser produces nothing.

The build-time guard logic is sound — bash is explicitly selected via SHELL in the Dockerfiles so set -o pipefail works correctly, and the &&-chain correctly propagates a non-zero subshell exit before reaching mkdir/chown. The unquoted ${dirs} variable works for the current path set but would silently break if any compose target ever gained a space. The parser only reads the shared extension field, so a per-service-only volume addition would not be pre-created without a clear error.

docker/utils/volume_mounts.py (parser coverage limited to the shared extension field) and both Dockerfiles (unquoted variable expansion in mkdir/chown)

Important Files Changed

Filename Overview
docker/utils/volume_mounts.py New utility that parses named-volume targets from docker-compose.yaml; solid guard logic, but only reads the shared extension field — per-service volumes would be silently missed.
docker/Dockerfile.base Adds a pre-USER RUN step to mkdir+chown all named-volume mount points; correctly uses set -o pipefail with bash shell; dirs variable unquoted in mkdir/chown is fragile against paths with spaces.
docker/Dockerfile.curobo Identical patch to Dockerfile.base; same unquoted ${dirs} fragility applies.
docker/test/test_dockerfile_nonroot.py Adds three well-structured static tests: parser unit test with regression guard for the specific volumes that triggered the bug, env-resolution test with monkeypatching, and Dockerfile wiring check.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["Dockerfile RUN (as root)\nset -o pipefail"] --> B["export DOCKER_ISAACSIM_ROOT_PATH\nDOCKER_ISAACLAB_PATH\nDOCKER_USER_HOME"]
    B --> C["isaaclab.sh -p volume_mounts.py\n| grep '^/'"]
    C --> D{"parse\nsucceeded?"}
    D -- "no (empty / unresolved)" --> E["Build FAILS\nnon-zero exit via &&"]
    D -- "yes" --> F["mkdir -p ${dirs}"]
    F --> G["chown -R isaaclab:isaaclab ${dirs}"]
    G --> H["USER isaaclab"]
    subgraph volume_mounts.py
        I["yaml.safe_load(docker-compose.yaml)"] --> J["filter type==volume from\nx-default-isaac-lab-volumes"]
        J --> K["os.path.expandvars() each target"]
        K --> L{"unresolved\n$ remaining?"}
        L -- yes --> M["stderr + exit 1"]
        L -- no --> N["print paths to stdout\nexit 0"]
    end
    C -.invokes.-> I
Loading

Reviews (1): Last reviewed commit: "Address review feedback on volume mount-..." | Re-trigger Greptile

Comment thread docker/Dockerfile.base
Comment on lines +178 to +179
&& mkdir -p ${dirs} \
&& chown -R isaaclab:isaaclab ${dirs}

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.

P2 Unquoted ${dirs} is fragile against paths with spaces

${dirs} is expanded without quotes in both mkdir -p and chown -R, relying on bash word-splitting to separate the newline-delimited paths into individual arguments. This works correctly for the current path set (no spaces), but would silently break if any future compose volume target contained a space — the path would be split mid-segment and create wrong directories. A more defensive pattern iterates the variable with while IFS= read -r dir.

The same pattern is present identically in Dockerfile.curobo (line 178–179 in that file).

Comment on lines +31 to +45
_VOLUMES_KEY = "x-default-isaac-lab-volumes"


def named_volume_targets(compose_path: str | os.PathLike = DEFAULT_COMPOSE) -> list[str]:
"""Return the in-container target path of every ``type: volume`` mount.

Args:
compose_path: Path to the compose file to read.

Returns:
The target paths, with any ``${VAR}`` references left intact.
"""
data = yaml.safe_load(Path(compose_path).read_text(encoding="utf-8"))
mounts = data.get(_VOLUMES_KEY) or []
return [m["target"] for m in mounts if m.get("type") == "volume"]

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.

P2 Parser misses volumes declared only in per-service volumes: sections

named_volume_targets reads exclusively from the x-default-isaac-lab-volumes YAML extension field. If a future service-specific volumes: entry is added directly under a service (rather than through the shared anchor), it will be silently omitted from the pre-create step and the volume mount point will come up root-owned at runtime. The guard in main() won't catch this because the shared list would still be non-empty.

This is a design trade-off, but the invariant "add a volume to compose and it's automatically prepared" only holds for the shared extension field, not for the entire compose file.

@hujc7
hujc7 merged commit 7d655dc into isaac-sim:release/3.0.0-beta2 Jun 10, 2026
59 of 61 checks passed
ooctipus pushed a commit that referenced this pull request Jun 11, 2026
…6122) (#6123)

Cherry-pick of #6122 to `release/3.0.0-beta2` for nvbug 6288406.

Makes `/isaac-sim/kit/data` writable by the non-root `isaaclab` user by
declaring it as a named volume, so the Kit kernel can write
`user.config.json` (the residual that #6082/#6095 did not cover —
`kit/data` was never a declared volume). Routes through the existing
`volume_mounts.py` + build-time `chown`; `docker-compose.yaml` is the
single source of truth.

Clean cherry-pick (release already has the #6095 volume-prep mechanism).
Validated on develop in #6122: on a clean rebuild, `/isaac-sim/kit/data`
is owned by uid 1000 and `user.config.json` writes succeed (pre-fix:
`Permission denied`).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants