-
-
Notifications
You must be signed in to change notification settings - Fork 289
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
feat: Get Docker endpoint from Docker context #1235
Conversation
This enables seamless integration with alternative Docker engines such as [Colima][1] or [OrbStack][2]. Without this change it requires a [specific configuration][3] that's far from obvious to figure out. [1]: https://github.com/abiosoft/colima [2]: https://orbstack.dev [3]: testcontainers/testcontainers-java#5034 (comment)
✅ Deploy Preview for testcontainers-dotnet ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Hi @0xced, |
I've address this concern in the follow-up commits by reading the configuration from the file system, like I re-used the code that performs |
docker context
commandLike the real `docker context` commands
I think I finally got an implementation that matches the Fortunately the Docker CLI source code is well commented! I don't like the many |
…et into 0xced-docker-context
Hey, very cool pull request 😎, thanks! I've been thinking about supporting this feature for a while, so it's awesome to see it. I added After that, we can go ahead and merge the PR. Thank you once more. |
I removed them. Let's see how many issues pop up. I think I've covered most error paths (except invalid JSON). I'm not a huge fan of swallowing errors because it makes it hard to help and provide support on Slack, etc. when we don't know the actual configuration and the potential underlying issue. It would be nice to have a logger available, but the auto-discovery mechanism runs too early. |
Please don't merge yet, I have found issues with the tests (the DockerConfig class is not well testable because of its static path properties). If you have a custom context some tests will fail locally but they will pass on CI as the current context will be the default one. |
src/Testcontainers/Builders/DockerDesktopEndpointAuthenticationProvider.cs
Show resolved
Hide resolved
We can overload the ctor to also accept the default |
36376cf
to
3f76d70
Compare
3f76d70
to
f5898ec
Compare
Ready for final review/merge? |
I just ran the test one more time on my machine and found a way where a test could fail. I just pushed a fix (266ee03) for the test. Hope you don't mind bringing in the So yes, ready for final review/merge. |
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.
💪
What does this PR do?
This pull request enables seamless integration with alternative Docker engines such as Colima or OrbStack.
These alternative engines make use of the Docker contexts feature to set themselves as the current Docker context.
Why is it important?
Without this change it requires a specific configuration that's far from obvious to figure out. It took me several hours fighting
NullReferenceException
because I'd only set theDOCKER_HOST
environment variable without settingTESTCONTAINERS_DOCKER_SOCKET_OVERRIDE
. The ryuk container would fail to start causing theNullReferenceException
.Related issues
How to test this PR
A new test has been added (
DockerProcessTest.GetCurrentEndpoint
) but installing Colima or OrbStack and actually using it with Testcontainers is the one true way to test this pull request. I did it with both Colima and OrbStack and it works on my machine.