Skip to content
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

fix: prefer cross-platform default DOCKER_HOST #1294

Merged
merged 1 commit into from
Jun 21, 2023

Conversation

danielorbach
Copy link
Contributor

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 🤗

@danielorbach danielorbach requested a review from a team as a code owner June 15, 2023 18:03
@netlify
Copy link

netlify bot commented Jun 15, 2023

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit 0442c3d
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-go/deploys/6491d91e40edc900086be41c
😎 Deploy Preview https://deploy-preview-1294--testcontainers-go.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

mdelapenya
mdelapenya previously approved these changes Jun 19, 2023
Copy link
Collaborator

@mdelapenya mdelapenya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the Docker client already does what I suggested in https://github.com/testcontainers/testcontainers-go/pull/1294/files#r1231789163, I think it's safer to honour the Docker client, as proposed in this PR.

Shaun approves 😎

image

Instead of blindly assuming a Linux operating system we can rely on the
docker client package to tell us the appropriate default docker host.
@sonarcloud
Copy link

sonarcloud bot commented Jun 20, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Collaborator

@mdelapenya mdelapenya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

In the case we detected this fails once we are able to test the project on Windows workers, I'll let you know to collaborate on an eventual fix.

Thank you so much for your dedication to testcontaines-go! 💪 🚀

@mdelapenya mdelapenya merged commit 215d34e into testcontainers:main Jun 21, 2023
62 checks passed
@mdelapenya mdelapenya self-assigned this Jun 21, 2023
@mdelapenya mdelapenya added the bug An issue with the library label Jun 21, 2023
@mehdihadeli
Copy link

@danielorbach Hi,
thanks for the fix,
Did you publish a new package release for this fix?

@mdelapenya
Copy link
Collaborator

@mehdihadeli we are going to release a new version soon, hopefully at the end of this week

@mehdihadeli
Copy link

Thanks

@danielorbach
Copy link
Contributor Author

@danielorbach Hi, thanks for the fix, Did you publish a new package release for this fix?

@mdelapenya I haven't a clue how to do this 😅

@mdelapenya
Copy link
Collaborator

Hey @danielorbach we core maintainers take care of the release process for the libraries, so no worries :)

In any case, I've just performed the release: https://github.com/testcontainers/testcontainers-go/releases/tag/v0.21.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue with the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Failing with "protocol not available, failed to create Docker provider" on Windows
3 participants