Open ash2k opened 1 week ago
Hi @ash2k thanks for opening this issue. There existed another issue on this, https://github.com/testcontainers/testcontainers-go/issues/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!
Proposal
Add support for Docker contexts. Currently the code below doesn't look at contexts:
https://github.com/testcontainers/testcontainers-go/blob/e22f2faa2e1accc96b2a00662005fcc17016497d/internal/core/docker_host.go#L99-L124
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.