Repository navigation
fix: honor active Docker context on macOS when /var/run/docker.sock is unavailable - #538
Conversation
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Active-context handling has unresolved context-name and TLS/SSH compatibility issues, with missing focused macOS tests.
Review effort: Lite
Findings: None
What changed in this PR
Updates Docker endpoint discovery on macOS to support active contexts and user socket fallbacks.
Changes:
- Adds Docker context inspection and socket fallback logic.
- Applies configuration to Docker clients, ping checks, and dry-run execution.
| File | Summary |
|---|---|
pkg/connectors/container_client.go |
Adds Docker host resolution and client integration. Requires context-name resolution, support for TLS/SSH metadata, focused macOS tests, and gofmt cleanup. |
cmd/testDryRun.go |
Configures the Docker host before dry-run Testcontainers usage. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Hey @Harsh4902, Just opened this PR for the macOS Docker context discovery, all CI checks are green. |
84b947b to
31eec2e
Compare
31eec2e to
fa22049
Compare
|
Hi @Harsh4902, Following up from the discussion on #539, I've updated the PR and added unit tests in Lemme know incase i've missed on something. |
fa22049 to
21f7bbd
Compare
|
@yada @Harsh4902, whenever you get time pls take a look |
|
Verified the merge result on macOS (build,
So the fix works for the reported case. It is not merged because of Harsh's open change request. His main concern (Sep 23) is to prefer a solution from the Docker SDK over our own fallback, and he asked on Oct 9 why the test hooks are package-level variables. @ish-g09 answered on Oct 9. @Harsh4902: could you tell us whether a bridge solution is acceptable until the SDK offers context support, and re-review? If yes, I would suggest limiting the fallback to macOS and an unset Disclosure: this comment was drafted with AI assistance, and the results were run locally. |
|
Thanks @ish-g09, and thanks @yada for verifying on macOS. I'm fine taking this as a bridge until we move to docker/go-sdk, since it only runs on darwin with no (1) only apply the inspected endpoint when it starts with (2) Use (3) Add a |
…able Signed-off-by: ish-g09 <ig.valiente09@gmail.com>
21f7bbd to
cdf8214
Compare
|
Thanks @Caesarsage and @yada for the review and verification!
I've also updated |
Thanks @Caesarsage, we can go with bridge solution as that's the only option. |
Caesarsage
left a comment
There was a problem hiding this comment.
Thanks @ish-g09 for the quick update, and @Harsh4902 for confirming. All three points are addressed and the tests pass. Merging as a stopgap until we move to docker/go-sdk (#539).
Description
ConfigureDockerHostinpkg/connectors/container_client.goto helpmicrocks-cliconnect to Docker on macOS when the default/var/run/docker.sockisn't available.docker context inspectso it honors whatever context the user is actively running (Docker Desktop, Colima, OrbStack, etc.).$HOME/.docker/run/docker.sockif context inspection isn't available.DOCKER_HOSTis already set or if/var/run/docker.sockexists (like on Linux).NewDockerClient(),PingDockerHost(), andcmd/testDryRun.goso bothmicrocks startandmicrocks test --dry-runcan reach Docker smoothly on modern macOS setups.pkg/connectors/container_client_test.gocovering active context resolution, socket fallback, and platform checks.Related issue(s)
Fixes #537
AI Disclosure
The code changes and unit tests were verified by me and I fully understand them. Used AI assistance to help structure unit test cases and mock subprocess patterns.
Testing
go test -v -run TestConfigureDockerHost ./pkg/connectors/...: passes (6/6 tests)go build ./...: passesgo test ./...: all packages pass