Repository navigation
[Docker] Make non-root image volume mount points writable by the isaaclab user (cherry-pick #6082 → 3.0.0-beta2) - #6095
Conversation
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.
There was a problem hiding this comment.
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
-
Single Source of Truth: Using
docker-compose.yamlas the canonical list of volume mounts and parsing it during build eliminates the risk of Dockerfiles drifting out of sync. -
Fail-Fast Design: The
set -o pipefailcombined with guards ensures build failures are loud and early rather than shipping images with unprepared mount points. -
Well-Documented: Both the code and PR description clearly explain the root cause (Docker volume ownership inheritance) and the fix mechanism.
-
Test Coverage: The new tests in
test_dockerfile_nonroot.pyvalidate:- Parser returns expected mount points
- Resolved paths are absolute
- Dockerfiles properly wire the parser with guards
Observations
-
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'sdocker-compose.yaml
-
Dockerfile Changes:
- Both
Dockerfile.baseandDockerfile.curobohave identical blocks - this is intentional since cuRobo doesn't inherit from base - The comment blocks are thorough and explain the "why" well
- Both
-
Test Design:
- Smart use of
pytest.importorskip("yaml")to gracefully skip parser tests if PyYAML isn't available in test env - The
_load_modulehelper handles the non-package nature of thedocker/directory
- Smart use of
Minor Suggestions (Non-blocking)
- Consider whether the
volume_mounts.pyparser 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 SummaryThis cherry-pick fixes permission errors in non-root Docker images by pre-creating every named-volume mount point and
Confidence Score: 4/5Safe 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
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
Reviews (1): Last reviewed commit: "Address review feedback on volume mount-..." | Re-trigger Greptile |
| && mkdir -p ${dirs} \ | ||
| && chown -R isaaclab:isaaclab ${dirs} |
There was a problem hiding this comment.
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).
| _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"] |
There was a problem hiding this comment.
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.
…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`).
Summary
release/3.0.0-beta2. Net diff is identical to the develop-side PR; applies cleanly with no conflicts.skrltraining aborts withPermissionErrorcreatinglogs/, and Isaac Sim emitsomni.datastorelock failures underkit/cache(tripping the CI training-log blacklist).isaaclabuser (uid/gid 1000) cannot write mount points the image left missing or root-owned.chowns every named-volume mount point before theUSERswitch, driven by a single source of truth —docker-compose.yaml, parsed bydocker/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 recursivechown), 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:rootand the uid-1000 runtime user is denied. The home-based volumes already inherited the right owner; the ones under/isaac-simand/workspace/isaaclabdid not (kit/cachewas created root-owned by a buildmkdir;logs/data_storage/docs/_builddid not exist in the image at all).3. Fix
3.1
docker/utils/volume_mounts.py— parses thetype: volumetargets out ofdocker-compose.yaml(the single source of truth) and resolves the${VAR}paths. Reuses PyYAML, already an IsaacLab dependency.3.2
Dockerfile.base/Dockerfile.curobo— beforeUSER isaaclab, invoke the parser andmkdir -p+chown -R isaaclab:isaaclabevery mount point, so fresh volumes inheritisaaclabownership.set -o pipefailplus a non-empty guard abort the build if the parse yields nothing, rather than silently shipping an unprepared mount point. The ROS 2 image buildsFROMbase and inherits the fix.3.3 Adding a volume to
docker-compose.yamlis now prepared automatically — no second list to keep in sync.4. Test
docker/test/test_dockerfile_nonroot.pyunit-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
13 passed); the parser test fails if compose drops a tracked volume.uid 1000, and the exact QA training (skrlAnymal-C) runs to completion with noPermissionErrorand zeroomni.datastorelock failures.6. Notes
docker/is not undersource/<pkg>(matches Make Isaac Lab Docker images run as non-root #5618).kit/cacheas root and runs Isaac Sim non-root, so its cache is unwritable even without a volume mount; the same step fixes it.