Skip to content

feat: add Linux and Podman socket detection to platform.js#269

Closed
brianwtaylor wants to merge 1 commit intoNVIDIA:mainfrom
brianwtaylor:fix/wsl2-native-docker-socket
Closed

feat: add Linux and Podman socket detection to platform.js#269
brianwtaylor wants to merge 1 commit intoNVIDIA:mainfrom
brianwtaylor:fix/wsl2-native-docker-socket

Conversation

@brianwtaylor
Copy link
Copy Markdown
Contributor

@brianwtaylor brianwtaylor commented Mar 18, 2026

Summary

The platform.js module introduced in #295 provides socket detection for macOS (Colima and Docker Desktop) but does not yet include Linux candidates — getDockerSocketCandidates() returns an empty array on non-Darwin platforms. This means detectDockerHost() relies entirely on DOCKER_HOST being pre-set on Linux, WSL2, and Podman environments.

This adds the standard Linux socket paths and Podman support to complete cross-platform coverage.

Addresses #137

Changes

bin/lib/platform.js — Extend getDockerSocketCandidates() for Linux with:

  • ~/.docker/run/docker.sock (Docker Desktop for Linux)
  • /run/docker.sock (native Docker / WSL2)
  • /var/run/docker.sock (native Docker fallback)
  • ~/.local/share/containers/podman/machine/podman.sock (Podman machine)
  • /run/user/<uid>/podman/podman.sock (rootless Podman)
  • ~/.local/share/containers/podman/machine/qemu/podman.sock (Podman QEMU)

Priority: Docker Desktop > native Docker > Podman

test/platform.test.js — 8 new tests (1 upstream test replaced), covering Linux candidate list, UID substitution, native Docker detection, /var/run fallback, Docker Desktop > native priority, native > Podman priority, Podman fallback, and rootless Podman.

Test plan

Automated Tests

node --test test/platform.test.js

22 tests (15 existing, 1 replaced, 8 added). All pass.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 18, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Detects container runtime and sockets: introduces detectContainerRuntime() (returns "docker", "podman", or null) and detectContainerSocket() (finds Colima, Docker Desktop, Docker, or Podman sockets). Updates preflight and CoreDNS logic to conditionally patch for Colima and adds tests for socket detection.

Changes

Cohort / File(s) Summary
Runtime & Preflight
bin/lib/onboard.js
Replaced isDockerRunning() with detectContainerRuntime() returning "docker", "podman", or null. Updated preflight checks and messages; health logging now distinguishes Podman vs Docker. CoreDNS patching is applied only when DOCKER_HOST indicates Colima.
Socket Detection & Runner exports
bin/lib/runner.js
Added detectContainerSocket(opts) which probes Colima, Docker Desktop, native Docker, and Podman sockets (includes rootless Podman via uid/XDG paths). If a socket is found and DOCKER_HOST is unset, sets DOCKER_HOST. Exported detectContainerSocket and added docstrings.
Tests
test/runner.test.js
New tests covering no-socket, Colima/Docker Desktop/Podman preference ordering, rootless Podman, XDG and QEMU socket paths, native /run/docker.sock and /var/run/docker.sock fallbacks, and preference combinations using mocked home, uid, and existsSync.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐇 I sniffed the sockets, hopped each trail,
Colima, Docker, Podman — I followed the trail,
Rootless burrows and XDG nooks found,
Preference ordered, no runtime unsound,
A happy rabbit hops where sockets abound 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title mentions 'platform.js' but the actual changes are in bin/lib/onboard.js and bin/lib/runner.js, not platform.js. Additionally, the main objective is Linux/Podman socket detection, not just the title suggests. Update the title to accurately reflect the actual files changed and primary objective, e.g., 'feat: add native Docker and Podman socket detection to runner.js and onboard.js'
✅ Passed checks (2 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

@brianwtaylor brianwtaylor force-pushed the fix/wsl2-native-docker-socket branch from d286cde to 0299e48 Compare March 18, 2026 01:45
@brianwtaylor
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 18, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
test/runner.test.js (1)

43-53: Consider adding a test for Docker Desktop vs native Linux priority.

The test suite verifies Docker Desktop is preferred over Podman, and Colima is preferred over native Linux, but there's no explicit test that Docker Desktop is preferred over /run/docker.sock. This would complete the priority chain verification.

🧪 Suggested test addition
it("prefers Docker Desktop over native Linux socket", () => {
  const dockerDesktopPath = "/home/test/.docker/run/docker.sock";
  const result = detectContainerSocket({
    home: "/home/test",
    existsSync: (p) => p === dockerDesktopPath || p === "/run/docker.sock",
    uid: 1000,
  });
  assert.equal(result, dockerDesktopPath);
});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/runner.test.js` around lines 43 - 53, Add a unit test to confirm
detectContainerSocket prefers Docker Desktop over the native Linux socket by
adding a test case (e.g., it("prefers Docker Desktop over native Linux socket"))
that calls detectContainerSocket with home="/home/test", uid=1000 and an
existsSync stub that returns true for "/home/test/.docker/run/docker.sock" and
"/run/docker.sock", then assert the result equals the Docker Desktop path; this
mirrors the existing Podman and Colima tests and completes the priority chain
coverage.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@test/runner.test.js`:
- Around line 43-53: Add a unit test to confirm detectContainerSocket prefers
Docker Desktop over the native Linux socket by adding a test case (e.g.,
it("prefers Docker Desktop over native Linux socket")) that calls
detectContainerSocket with home="/home/test", uid=1000 and an existsSync stub
that returns true for "/home/test/.docker/run/docker.sock" and
"/run/docker.sock", then assert the result equals the Docker Desktop path; this
mirrors the existing Podman and Colima tests and completes the priority chain
coverage.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2338b4ef-f6f1-4fa2-a0fd-f6b4d221f8b0

📥 Commits

Reviewing files that changed from the base of the PR and between 0d1d2d8 and 0299e48.

📒 Files selected for processing (3)
  • bin/lib/onboard.js
  • bin/lib/runner.js
  • test/runner.test.js

@wscurran wscurran added the Platform: Windows/WSL Support for Windows Subsystem for Linux label Mar 18, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
test/runner.test.js (1)

20-148: Consider a small helper to reduce repeated setup boilerplate.

Most tests repeat the same detectContainerSocket({ home, existsSync, uid }) scaffolding. A tiny helper would make additions easier and reduce copy/paste noise.

♻️ Optional refactor sketch
+const detect = (existsSync, { home = "/home/test", uid = 1000 } = {}) =>
+  detectContainerSocket({ home, existsSync, uid });

-    const result = detectContainerSocket({
-      home: "/home/test",
-      existsSync: (p) => p === dockerDesktopPath,
-      uid: 1000,
-    });
+    const result = detect((p) => p === dockerDesktopPath);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/runner.test.js` around lines 20 - 148, Extract the repeated test
scaffolding into a small helper function (e.g., makeDetectArgs or runDetect)
used by all test cases so each test calls detectContainerSocket(makeDetectArgs({
home: "/home/test", existsSync: ..., uid: ... })) or runDetect({...}) to reduce
duplication; update all test cases to call the helper instead of repeating the
object literal, keeping the existing uses of detectContainerSocket and
preserving custom existsSync/uid values per test.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/runner.test.js`:
- Around line 66-87: Add a unit test to assert native Docker socket is preferred
over Podman by calling detectContainerSocket with both "/var/run/docker.sock"
and the Podman path present (simulate existsSync returning true for both) and
asserting the returned path equals "/var/run/docker.sock"; place it alongside
the existing Colima/Podman tests and mirror their structure (use home,
existsSync, uid) to lock in the native-over-Podman priority.

---

Nitpick comments:
In `@test/runner.test.js`:
- Around line 20-148: Extract the repeated test scaffolding into a small helper
function (e.g., makeDetectArgs or runDetect) used by all test cases so each test
calls detectContainerSocket(makeDetectArgs({ home: "/home/test", existsSync:
..., uid: ... })) or runDetect({...}) to reduce duplication; update all test
cases to call the helper instead of repeating the object literal, keeping the
existing uses of detectContainerSocket and preserving custom existsSync/uid
values per test.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 66c422a8-b5b2-47aa-a395-8294f905ddaf

📥 Commits

Reviewing files that changed from the base of the PR and between 0299e48 and 5e9c0dc.

📒 Files selected for processing (1)
  • test/runner.test.js

Comment thread test/runner.test.js Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
test/runner.test.js (1)

142-149: Add a direct /var/run/docker.sock over Podman priority test.

Line 142 currently validates /var/run/docker.sock only as a standalone fallback. Add a paired test where both /var/run/docker.sock and Podman exist, so native-over-Podman priority is covered for both native socket paths.

✅ Suggested test addition
+  it("prefers /var/run/docker.sock over Podman", () => {
+    const podmanPath = "/home/test/.local/share/containers/podman/machine/podman.sock";
+    const result = detectContainerSocket({
+      home: "/home/test",
+      existsSync: (p) => p === "/var/run/docker.sock" || p === podmanPath,
+      uid: 1000,
+    });
+    assert.equal(result, "/var/run/docker.sock");
+  });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/runner.test.js` around lines 142 - 149, Add a new test in
test/runner.test.js that calls detectContainerSocket with existsSync returning
true for both "/var/run/docker.sock" and the Podman socket path (e.g.,
"/run/podman/podman.sock" or the code's Podman candidate) and assert the result
is "/var/run/docker.sock"; this complements the existing standalone fallback
test and ensures detectContainerSocket prefers the native Docker socket over
Podman when both exist (refer to detectContainerSocket to locate the socket
candidates and use the same test harness pattern as the existing cases).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@test/runner.test.js`:
- Around line 142-149: Add a new test in test/runner.test.js that calls
detectContainerSocket with existsSync returning true for both
"/var/run/docker.sock" and the Podman socket path (e.g.,
"/run/podman/podman.sock" or the code's Podman candidate) and assert the result
is "/var/run/docker.sock"; this complements the existing standalone fallback
test and ensures detectContainerSocket prefers the native Docker socket over
Podman when both exist (refer to detectContainerSocket to locate the socket
candidates and use the same test harness pattern as the existing cases).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 451790b8-8d2a-433e-94eb-25ac3fe56298

📥 Commits

Reviewing files that changed from the base of the PR and between 5e9c0dc and 819445a.

📒 Files selected for processing (1)
  • test/runner.test.js

@brianwtaylor brianwtaylor force-pushed the fix/wsl2-native-docker-socket branch from 819445a to 8fcff22 Compare March 18, 2026 20:36
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
test/runner.test.js (1)

12-17: Optional: extract a small helper to reduce repetitive test scaffolding.

Most test bodies repeat the same detectContainerSocket({ home, existsSync, uid }) shape; a local helper would make cases shorter and easier to scan.

♻️ Example refactor
 describe("detectContainerSocket", () => {
+  function detectWith({ home = "/home/test", existsSync, uid = 1000 }) {
+    return detectContainerSocket({ home, existsSync, uid });
+  }
+
   it("returns null when no sockets exist", () => {
-    const result = detectContainerSocket({
-      home: "/nonexistent",
-      existsSync: () => false,
-      uid: 1000,
-    });
+    const result = detectWith({ home: "/nonexistent", existsSync: () => false });
     assert.equal(result, null);
   });

Also applies to: 23-29, 35-41, 47-53, 58-64, 70-76, 81-87, 92-98, 104-110, 115-121, 125-131, 134-140, 143-149, 153-159

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/runner.test.js` around lines 12 - 17, Extract a small test helper to
reduce repetition: add a local function (e.g., runDetect or makeDetectInput) in
the test file that supplies the common shape detectContainerSocket expects
(home, existsSync, uid) and accepts overrides, then replace repeated calls like
detectContainerSocket({ home: "/nonexistent", existsSync: () => false, uid: 1000
}) with the helper (e.g., runDetect({ home: "/nonexistent", existsSync: () =>
false, uid: 1000 }) or runDetect({ uid: 1000 }) using defaults). Update all test
cases referencing detectContainerSocket to use this helper to keep tests shorter
and easier to scan while preserving the same assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@bin/lib/runner.js`:
- Around line 12-13: Update the docstring that currently reads "Detect a
container runtime socket (Colima first, then Docker Desktop, then Podman)." to
match the actual detection order implemented in the code: mention Colima first,
then native Docker sockets, then Podman (i.e., "Colima -> Docker (native) ->
Podman"); locate and edit the comment block that begins with "Detect a container
runtime socket (Colima first, then Docker Desktop, then Podman)." so the text
accurately reflects the implemented detection sequence.

---

Nitpick comments:
In `@test/runner.test.js`:
- Around line 12-17: Extract a small test helper to reduce repetition: add a
local function (e.g., runDetect or makeDetectInput) in the test file that
supplies the common shape detectContainerSocket expects (home, existsSync, uid)
and accepts overrides, then replace repeated calls like detectContainerSocket({
home: "/nonexistent", existsSync: () => false, uid: 1000 }) with the helper
(e.g., runDetect({ home: "/nonexistent", existsSync: () => false, uid: 1000 })
or runDetect({ uid: 1000 }) using defaults). Update all test cases referencing
detectContainerSocket to use this helper to keep tests shorter and easier to
scan while preserving the same assertions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5b8a32b5-3cbf-4553-99d6-1fdfd4f3fb31

📥 Commits

Reviewing files that changed from the base of the PR and between 819445a and 8fcff22.

📒 Files selected for processing (3)
  • bin/lib/onboard.js
  • bin/lib/runner.js
  • test/runner.test.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • bin/lib/onboard.js

Comment thread bin/lib/runner.js Outdated
After the platform.js refactor in #295, getDockerSocketCandidates()
returns an empty array on Linux, so detectDockerHost() never finds a
socket on native Linux or WSL2 unless DOCKER_HOST is already set.

Add the standard Linux Docker socket paths (/run/docker.sock,
/var/run/docker.sock), Docker Desktop for Linux, and three Podman
socket paths (machine, rootless, QEMU) with the priority order:

  Docker Desktop > native Docker > Podman

Includes 9 new tests covering Linux detection, priority chain,
rootless Podman UID substitution, and fallback behavior.
@brianwtaylor brianwtaylor changed the title fix: detect native Docker socket on Linux and WSL2 fix: add Linux and Podman socket detection to platform.js Mar 19, 2026
@brianwtaylor brianwtaylor force-pushed the fix/wsl2-native-docker-socket branch from c39110f to 55f8559 Compare March 19, 2026 02:50
@brianwtaylor brianwtaylor changed the title fix: add Linux and Podman socket detection to platform.js feat: add Linux and Podman socket detection to platform.js Mar 19, 2026
@brianwtaylor brianwtaylor closed this by deleting the head repository Mar 20, 2026
mafueee pushed a commit to mafueee/NemoClaw that referenced this pull request Mar 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Platform: Windows/WSL Support for Windows Subsystem for Linux

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants