Skip to content

[DOCKER] Refactor bash.sh: auto-detect rootless, add --shell, TVM_DEV_MOUNTS#18854

Merged
tqchen merged 2 commits intoapache:mainfrom
tqchen:refactor-docker-bash-sh
Feb 28, 2026
Merged

[DOCKER] Refactor bash.sh: auto-detect rootless, add --shell, TVM_DEV_MOUNTS#18854
tqchen merged 2 commits intoapache:mainfrom
tqchen:refactor-docker-bash-sh

Conversation

@tqchen
Copy link
Member

@tqchen tqchen commented Feb 28, 2026

Summary

Refactor docker/bash.sh incorporating lessons from tdev's docker/run_container.sh:

  • Auto-detect rootless: Replace $DOCKER_IS_ROOTLESS env var with docker info query (env var kept as CI override)
  • --shell <name>: New flag to specify interactive shell (e.g., --shell zsh)
  • TVM_DEV_MOUNTS: New env var for declarative mount configuration (space-separated paths)
  • GPU cleanup: Remove legacy nvidia-docker detection and Vulkan ICD mounting; use --gpus all
  • Code organization: Extract detect_rootless(), validate_mount() helpers; organize into labeled sections

All existing flags and CI behavior preserved. Backwards compatible.

Test plan

  • bash -n docker/bash.sh — no syntax errors
  • bash docker/bash.sh --help — shows updated usage
  • Manual test in CI-compatible container

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the docker/bash.sh script to enhance its flexibility and maintainability for managing Docker development environments. The changes streamline the user experience by introducing automatic rootless Docker detection, providing a new option for specifying interactive shells, and enabling declarative bind mounts via an environment variable. It also simplifies GPU setup and improves the overall structure of the script, making it more robust and easier to understand.

Highlights

  • Auto-detect rootless Docker: The script now automatically detects if the Docker daemon is running in rootless mode by querying docker info, falling back to the DOCKER_IS_ROOTLESS environment variable as an override for CI.
  • New --shell option: A new --shell <name> flag has been added, allowing users to specify an interactive shell (e.g., zsh) to use instead of bash when entering an auto-interactive Docker session.
  • New TVM_DEV_MOUNTS environment variable: A new environment variable, TVM_DEV_MOUNTS, is introduced for declarative mount configuration. It accepts a space-separated list of paths (e.g., /path/to/dir or /src:/dst), with source paths validated before mounting.
  • Simplified GPU setup: Legacy nvidia-docker detection and explicit Vulkan ICD mounting have been removed. GPU containers now consistently use the --gpus all flag for simplified configuration.
  • Improved code organization: The bash.sh script has been refactored into clearly labeled sections (Constants, Helpers, Argument Parsing, etc.) and helper functions like detect_rootless() and validate_mount() have been extracted for better readability and maintainability.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • docker/bash.sh
    • Updated usage message to include --shell option and TVM_DEV_MOUNTS environment variable.
    • Introduced script sections for better organization (Constants, Helpers, Argument Parsing, Image Resolution, Mount Construction, Environment Construction, GPU/Device Setup, Entry Command, Final Docker Run).
    • Moved default variable declarations and REPO_MOUNT_POINT logic to the 'Constants and defaults' section.
    • Added detect_rootless() helper function to auto-detect Docker rootless mode using docker info or DOCKER_IS_ROOTLESS env var.
    • Added validate_mount() helper function to check if a mount source path exists.
    • Implemented parsing for the new --shell argument.
    • Refined handling of DOCKER_IS_ROOTLESS around dev_common.sh sourcing to preserve user-set values.
    • Added logic to process TVM_DEV_MOUNTS environment variable for additional bind mounts, validating source paths.
    • Included logic to automatically mount the .git common directory when running from a git worktree.
    • Removed legacy nvidia-docker detection and explicit Vulkan ICD mounting.
    • Standardized GPU setup to use --gpus all for GPU/CUDA images.
    • Modified the entry command to use the USER_SHELL if provided and the default command is bash.
    • Updated the condition for using with_the_same_user script to ! detect_rootless instead of checking DOCKER_IS_ROOTLESS directly.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request is a great refactoring of docker/bash.sh. It improves code organization, adds useful features like --shell and TVM_DEV_MOUNTS, and modernizes GPU handling by removing legacy nvidia-docker code. The auto-detection of rootless docker is also a nice improvement. My review includes a few suggestions to improve robustness, correctness, and conciseness in argument parsing and helper functions.

@tqchen tqchen merged commit ae1f8f7 into apache:main Feb 28, 2026
15 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