testcontainers-go
testcontainers-go copied to clipboard
feat: support reading Docker host from the current Docker context
- feat: support reading Docker context
- chore: move read Docker config to the core
- chore: read docker config more consistently
- chore: extract to a parse function to detect remote docker hosts
- docs: add Docker context to docs
What does this PR do?
This PR adds a new step in the Docekr host discovery algorithm, extracting the Docker host from the current Docker context. To achieve that, we are copying code from the docker/cli project,
as we don't want to receive all the dependencies from that project (please see docker_context.go file). In the end, it just does the following:
- list all contexts from the default location: docker config path / context / meta / contextA / meta.json
- get the current context from the docker config, located at docker config path / config.json
- read the meta.json file for the current context, extracting the host endpoint
- use that host endpoint for the Docker Host.
NOTE: The default docker config path lives in $HOME/.docker.
This PR also reduces the complexity in discovering the default bridge network, so instead of having to detect if a network named Bridge exists, it simply delegates to the container runtime to detect it under the hood.
Why is it important?
It will simplify the experience using different container runtimes, as this change means that with just setting the current context, testcontainers-go will use that container runtime.