fix: prefer cross-platform default DOCKER_HOST #1294
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Instead of blindly assuming a Linux operating system we can rely on the docker client package to tell us the appropriate default docker host.
What does this PR do?
I've changed the default
DOCKER_HOST
socket from its Linux value by relying on Docker's client library to supply their cross-platform values.I chose to parse their value as a URL (I say
parseURL
doing the same) to separate between the schema and the path.I was defensive because I am unfamiliar with the codebase - that's the reason for the suffix/prefix validations. Also, upon errors (url parsing, or unknown schema) I fallback to the predefined default rendering the changes of this PR a no-op.
Why is it important?
Windows users really want to use test-containers too! 🪟🐳
Before release
v0.20.1
the host was not explicitly set to a default, hence it fell-back to the docker library's default anyways.Related issues
How to test this PR
I haven't been able to run all the tests because I currently use a Windows machine. However, I ran some container-based tests (that broke with release
v0.20.1
) on my machine and they have passed 🤗