-
-
Notifications
You must be signed in to change notification settings - Fork 492
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
[Enhancement]: support Docker contexts #2607
Comments
Hi @ash2k thanks for opening this issue. There existed another issue on this, #815, but it was closed as Done as it just targeted colima. I think we can keep this issue as reference for the context awareness. On the other hand, I can confirm we would need to tackle this initiative in a cross-lang manner, as it should be implemented in a similar way for all the Testcontainers libraries, to keep the seamless experience we want to provide. So please let me put this in the back burner until we have clear lines on how to abstract the interactions with the Docker context, so that it's "implementable" across all languages. Hope you understand. In any case, I encourage you to open a discussion a draft a design doc if you're interested; I'm pretty sure it will help us drive the conversation from Go to other languages. Cheers! |
I think that #815 was incorrectly marked as Done as I still had to resolve to
workaround |
@RafalSkolasinski would you like to contribute it to the docs? |
@mdelapenya the only contribution to docs now could be linking this issue on https://golang.testcontainers.org/system_requirements/using_colima/ to warn people that this feature is currently not working correctly, as reading testcontainers-go/docs/system_requirements/using_colima.md Lines 6 to 8 in 4c5f1bd
one would expect it should all be fine |
Changing just the context is indeed broken. However here is a workaround to avoid linking: DOCKER_HOST=$(docker context inspect | jq ".[0].Endpoints.docker.Host" -r) \
TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=$(docker context inspect | jq ".[0].Endpoints.docker.Host" -r) \
go test $(FLAGS) -cover ./... this gets the current docker context's endpoint and sets it as an env var |
Proposal
Add support for Docker contexts. Currently the code below doesn't look at contexts:
testcontainers-go/internal/core/docker_host.go
Lines 99 to 124 in e22f2fa
I'm running Rancher Desktop and the Docker unix socket does not exist at the usual location. Hence, test containers fails to find it. I'm getting an error
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?: failed to create container
.My current context is a different one and the socket file is somewhere else:
If I set
DOCKER_HOST=unix:///Users/mike/.rd/docker.sock
, everything works fine. But this shouldn't be necessary.If this enhancement is implemented, the code should probably print the current context name (for debugging), not just the path to the socket file.
The text was updated successfully, but these errors were encountered: