Repository navigation
feat(install): ensure Docker is installed and user is in docker group #3314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
cae79bd
20a2248
3cd3ecc
8169e4a
c55cc5c
ba8190a
ba01d2f
d0445b6
6a59bfd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1673,6 +1673,72 @@ run_onboard() { | |||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Make sure Docker is installed and the current user can run it without | ||||||||||||||||||||||||||
| # sudo. If we install Docker or add the user to the docker group, exit with | ||||||||||||||||||||||||||
| # instructions to relogin/newgrp — Linux only loads group membership at | ||||||||||||||||||||||||||
| # login, so the rest of this script (onboard, etc.) would fail otherwise. | ||||||||||||||||||||||||||
| # Skipped on macOS (Docker Desktop) and inside WSL (host-managed Docker). | ||||||||||||||||||||||||||
| ensure_docker() { | ||||||||||||||||||||||||||
| case "$(uname -s)" in | ||||||||||||||||||||||||||
| Darwin | MINGW* | MSYS*) return 0 ;; | ||||||||||||||||||||||||||
| esac | ||||||||||||||||||||||||||
| if [ -n "${WSL_DISTRO_NAME:-}" ] || [ -n "${WSL_INTEROP:-}" ]; then | ||||||||||||||||||||||||||
| return 0 | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
| # Fast path: docker info works → already set up (root, or already-active group). | ||||||||||||||||||||||||||
| if docker info >/dev/null 2>&1; then | ||||||||||||||||||||||||||
| return 0 | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| local group_added=0 | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if ! command -v docker >/dev/null 2>&1; then | ||||||||||||||||||||||||||
| info "Docker is not installed." | ||||||||||||||||||||||||||
| info "The next step uses sudo to install Docker system-wide via the official convenience script. You may be prompted for your password." | ||||||||||||||||||||||||||
| local docker_tmp | ||||||||||||||||||||||||||
| docker_tmp="$(mktemp)" | ||||||||||||||||||||||||||
| if ! curl -fsSL https://get.docker.com -o "$docker_tmp"; then | ||||||||||||||||||||||||||
| rm -f "$docker_tmp" | ||||||||||||||||||||||||||
| error "Failed to download the Docker convenience script from https://get.docker.com" | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
| verify_downloaded_script "$docker_tmp" "Docker installer" | ||||||||||||||||||||||||||
| if ! sudo sh "$docker_tmp"; then | ||||||||||||||||||||||||||
| rm -f "$docker_tmp" | ||||||||||||||||||||||||||
| error "Docker install failed. Install Docker manually and re-run." | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
| rm -f "$docker_tmp" | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if command -v systemctl >/dev/null 2>&1 \ | ||||||||||||||||||||||||||
| && ! sudo -n systemctl is-active --quiet docker 2>/dev/null \ | ||||||||||||||||||||||||||
| && ! systemctl is-active --quiet docker 2>/dev/null; then | ||||||||||||||||||||||||||
| info "The Docker daemon is not running." | ||||||||||||||||||||||||||
| info "The next step uses sudo to enable and start the docker.service unit. You may be prompted for your password." | ||||||||||||||||||||||||||
| if ! sudo systemctl enable --now docker 2>/dev/null; then | ||||||||||||||||||||||||||
| warn "Could not enable docker.service — will verify daemon accessibility below." | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if ! id -nG "$USER" 2>/dev/null | tr ' ' '\n' | grep -qx docker; then | ||||||||||||||||||||||||||
| info "Your user '$USER' is not in the docker group." | ||||||||||||||||||||||||||
| info "The next step uses sudo to add you to the group so docker works without sudo. You may be prompted for your password." | ||||||||||||||||||||||||||
| sudo usermod -aG docker "$USER" | ||||||||||||||||||||||||||
| group_added=1 | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if [ "$group_added" = "1" ]; then | ||||||||||||||||||||||||||
| printf "\n" | ||||||||||||||||||||||||||
| info "Docker setup complete. To finish:" | ||||||||||||||||||||||||||
| info " 1) Run: newgrp docker (or log out and log back in)" | ||||||||||||||||||||||||||
| info " 2) Re-run: curl -fsSL https://www.nvidia.com/nemoclaw.sh | bash" | ||||||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
Comment on lines
+1753
to
+1758
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don’t tell users to rerun a different installer invocation. This exit path runs after args/env have already been parsed, so the hardcoded one-liner drops flags like Suggested tweak- info " 2) Re-run: curl -fsSL https://www.nvidia.com/nemoclaw.sh | bash"
+ info " 2) Re-run the same installer command you used originally, with the same flags/env."📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if ! docker info >/dev/null 2>&1; then | ||||||||||||||||||||||||||
| error "Docker is installed but not reachable. Try: sudo systemctl start docker" | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # Main | ||||||||||||||||||||||||||
| # --------------------------------------------------------------------------- | ||||||||||||||||||||||||||
| main() { | ||||||||||||||||||||||||||
|
|
@@ -1725,6 +1791,8 @@ main() { | |||||||||||||||||||||||||
| # still collect acceptance before Node.js or the CLI are installed. | ||||||||||||||||||||||||||
| preflight_usage_notice_prompt | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| ensure_docker | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| _INSTALL_START=$SECONDS | ||||||||||||||||||||||||||
| print_banner | ||||||||||||||||||||||||||
| bash "${SCRIPT_DIR}/setup-jetson.sh" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
Doesdocker infouse the current Docker context and theDOCKER_HOST/DOCKER_CONTEXTenvironment variables, and what is the recommended way for a Linux shell script to force a check against the local Docker daemon/socket?💡 Result:
Yes.
docker info(alias ofdocker system info) connects to whatever daemon endpoint the Docker CLI is configured to use, which is determined by the active Docker context unless overridden by higher-priority connection settings likeDOCKER_HOST/--host/-H. The Docker docs state that commands run against the current context “unless overridden with environment variables such asDOCKER_HOSTandDOCKER_CONTEXT,” or with--context/--hostflags [1]. Also,DOCKER_CONTEXToverrides the context selected viadocker context usewhen the environment variable is set [1][2]. Separately, the CLI reference describesDOCKER_HOSTas the “Daemon socket to connect to” and that-c/--contextoverridesDOCKER_HOSTonly relative to default context selection; and the context commands explainDOCKER_HOST/DOCKER_CONTEXTand flags affect what daemon is used [3]. Thedocker infopage shows “Client/Context: …” in its output, confirming it reports the client-side context it’s using [4]. Recommended way (Linux shell script) to force a check against the local Docker daemon/socket: rundocker infowith an explicit host override to the local Unix socket and clear any env overrides that could redirect the CLI. Docker provides troubleshooting guidance that ifDOCKER_HOSTis set then the Docker client is connecting to a daemon on that host, and recommends unsetting it when you want local behavior [5]. So in a script, do something like: unset DOCKER_HOST DOCKER_CONTEXT export DOCKER_CONTEXT=default # optional; ensures you’re not using a non-local named context # Force local daemon via unix socket (typical rootful Docker): docker --host unix:///var/run/docker.sock info >/dev/null If you’re using rootless Docker, the socket is typically under$XDG_RUNTIME_DIR/docker.sockas documented; you’d use that path instead of/var/run/docker.sock[6]. This approach forces the check against the intended local socket regardless of whatever current context the user/session has selected viadocker context useor environment variables such asDOCKER_CONTEXT, becauseDOCKER_HOSTis either unset or the connection is overridden explicitly via--host/socket URI [1][5].Citations:
🏁 Script executed:
Repository: NVIDIA/NemoClaw
Length of output: 2330
Force Docker reachability checks against the local daemon socket, not the active Docker context.
The bare
docker infochecks on lines 1689-1691, 1725-1728, and 1761-1762 honor the user's current Docker context andDOCKER_HOSTenvironment variables. If the user has Docker pointed at a remote or stale endpoint, the preflight will falsely fail or take the wrong remediation path even though the local daemon is accessible. Explicitly target the local Unix socket usingdocker --host unix:///var/run/docker.sock info(or the rootless equivalent under$XDG_RUNTIME_DIR/docker.sock).🤖 Prompt for AI Agents