Skip to content

Preserve environment when attaching to Docker - #1546

Merged
qianl-nv merged 7 commits into
mainfrom
qianl/fix/docker-attach-path
Nov 5, 2026
Merged

qianl-nv merged 7 commits into
mainfrom
qianl/fix/docker-attach-path

Conversation

@qianl-nv

@qianl-nv qianl-nv commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Preserve the container image environment when attaching or running commands as the host user. Use Docker user selection directly instead of switching users inside the container.
Reported by 7044965

Why this change?

Main uses su <user> -c loads /etc/environment through PAM and replaces the image PATH with the system default, when re-attaching to a running container. Commands such as isaaclab.sh -p then fail because the Isaac Lab launcher is no longer on PATH.

What changes?

  • Attach to a running Arena container with docker exec --user "$(id --user --name)".
  • Update contributor, setup, test, and evaluation commands to use the same direct execution pattern.
  • Rely on the image PATH, working directory, and /etc/passwd identity. Existing containers require no rebuild or recreation.

Usage example

Before:

docker exec "$ARENA_CONTAINER" su "$(id -un)" -c \
  "cd /workspaces/isaaclab_arena && isaaclab.sh -p script.py"

After:

docker exec --user "$(id --user --name)" "$ARENA_CONTAINER" isaaclab.sh -p script.py

Validation

  • Verified the updated command against an existing container without rebuilding it.
  • Verified host-user identity, HOME, PATH, repository working directory, Isaac Lab launcher resolution, Arena import, argument forwarding, and exit-status propagation.
  • Verified root commands still report the root identity.

@qianl-nv
qianl-nv marked this pull request as ready for review October 28, 2026 02:56
@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The change appears safe to merge.

Summary

Reattaching to a running Docker container now preserves the Arena environment when switching users.

  • Reattaching keeps the Arena Python environment available.

Reviews (1) · Last reviewed commit: "Preserve environment when attaching to D..." · Reviewed by Greptile

Comment thread docker/run_docker.sh Resolved
Comment thread docker/run_docker.sh Resolved
@arena-review-bot

arena-review-bot Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

🤖 Isaac Lab-Arena Review Bot

Summary

The PR changes run_docker.sh and the docker exec commands in AGENTS.md and four skills to use docker exec --user "$(id -un)". That keeps the image's PATH and working directory, where su used to reset PATH. It also adds a /usr/local/bin/isaaclab.sh launcher for shells where su or sudo reset PATH, and sets USER/LOGNAME for the whole container. Both points from the earlier review are fixed: the docs no longer use su, and attaching uses the host user. The main fix looks right. My comments are about the two extra pieces, which nothing in the repo still needs.

Design, Boundaries & Scope

Switching to docker exec --user fixes the problem where it starts. After that change, the new launcher only helps after a manual su or sudo inside the container. The container-wide USER/LOGNAME have no reader in Arena or Isaac Lab, and they give root shells the host user's name. Unless I've missed a workflow, the PR could be just the docker exec --user change plus the doc updates.

Findings

🔵 Improvement: docker/setup/configure_shell.sh:7: With docker exec --user, the image PATH lists $ISAACLAB_PATH before /usr/local/bin. This launcher therefore only runs after a manual su/sudo, and no doc, CI job, or script in the repo does that. Could we drop it, or name the workflow that still needs it?

🔵 Improvement: docker/run_docker.sh:177: USER/LOGNAME also apply to docker exec without --user, which runs as root. Root processes then report the host user. For example, getpass.getuser() makes torch's compile cache /tmp/torchinductor_<host user>, and that directory ends up owned by root on the host's /tmp. Processes started with --user already get the right name from /etc/passwd. What needs these variables?

🔵 Improvement: skills/developer/dev-container/SKILL.md:77: The command on line 69 works in containers created before this change. The launcher sentence and the "need to be recreated" note suggest it doesn't. Could we drop both? The rebuild section already says to recreate the container after a rebuild.

Notes

  • I didn't build the image or run the commands.
  • I checked the launcher's assumptions against a recent local copy of Isaac Lab's isaaclab.sh, not the pinned submodule commit.
  • I couldn't check whether Isaac Sim's Kit binaries read USER.
  • At review time, the Arena image build and the cuRobo dependency check were still running in CI. Pre-commit, the docs build, and the cuRobo image build passed.
  • CI doesn't use run_docker.sh, so the new attach command isn't covered there.

Verdict

Minor fixes needed

@qianl-nv

Copy link
Copy Markdown
Collaborator Author

/review

Comment thread docker/setup/configure_shell.sh Resolved
Comment thread docker/run_docker.sh Resolved
Comment thread skills/developer/dev-container/SKILL.md Resolved
qianl-nv added a commit that referenced this pull request Oct 31, 2026
#1546
commit 8165685

Signed-off-by: Qian Lin <qianl@nvidia.com>
Signed-off-by: Qian Lin <qianl@nvidia.com>
Signed-off-by: Qian Lin <qianl@nvidia.com>
Signed-off-by: Qian Lin <qianl@nvidia.com>
Signed-off-by: Qian Lin <qianl@nvidia.com>
Signed-off-by: Qian Lin <qianl@nvidia.com>
@qianl-nv
qianl-nv force-pushed the qianl/fix/docker-attach-path branch from 8165685 to 4ca3c06 Compare November 3, 2026 10:16
Signed-off-by: Qian Lin <qianl@nvidia.com>
@qianl-nv

qianl-nv commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator Author

/review

@arena-review-bot

Copy link
Copy Markdown
Contributor

The review stopped before it finished. Please run /review to retry.

Requested in this comment.

@qianl-nv

qianl-nv commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator Author

/review

@arena-review-bot

Copy link
Copy Markdown
Contributor

The review could not start. Please run /review to retry.

Requested in this comment.

@david-tingdahl-nvidia david-tingdahl-nvidia left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice! I believe this is the canonical way of executing docker as a given user

Comment thread AGENTS.md Resolved
Signed-off-by: Qian Lin <qianl@nvidia.com>
@qianl-nv
qianl-nv enabled auto-merge (squash) November 5, 2026 11:03
@qianl-nv
qianl-nv merged commit 7c056bb into main Nov 5, 2026
10 checks passed
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.

2 participants