-
-
Notifications
You must be signed in to change notification settings - Fork 586
fix: preserve unix socket schema in testcontainersHostFromProperties #3213
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
Merged
mdelapenya
merged 2 commits into
testcontainers:main
from
knqyf263:fix-unix-socket-parsing
Sep 5, 2025
Merged
fix: preserve unix socket schema in testcontainersHostFromProperties #3213
mdelapenya
merged 2 commits into
testcontainers:main
from
knqyf263:fix-unix-socket-parsing
Sep 5, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This fix addresses an issue where unix socket URLs like 'unix:///var/run/docker.sock' would have their schema stripped when parsed through testcontainersHostFromProperties, causing Docker client initialization to fail. The solution validates the URL format but preserves the original URL with schema for Docker client compatibility, while maintaining backward compatibility for other use cases. - Fix testcontainersHostFromProperties to preserve unix socket schema - Add comprehensive test coverage for unix socket handling - Ensure TCP hosts continue to work as expected
✅ Deploy Preview for testcontainers-go ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
* main: (33 commits) feat(registry): add helper functions to pull and tag images (testcontainers#3275) fix(reaper): remove termSignal override (testcontainers#3261) chore(deps): bump ryuk to v0.13.0, which uses scratch as base image (testcontainers#3274) chore(release): refine release script to update inter-module dependencies (testcontainers#3273) fix(registry): update `WithHtpasswd` to use `os.CreateTemp` instead of `os.Create` with `filepath.Join`. (testcontainers#3272) chore(deps): bump github.com/docker/docker from 28.2.2+incompatible to 28.3.3+incompatible (testcontainers#3270) chore(postgres): use require.NotNil instead of assert.NotNil (testcontainers#3252) fix(nats): use wait for listening port instead of wait for log (testcontainers#3256) chore(deps): bump github.com/go-viper/mapstructure/v2 (testcontainers#3267) fix(postgres): snapshot restore (testcontainers#3264) fix(dockermcpgateway): use duckduckgo instead of brave (testcontainers#3247) feat: add Solace pubsub+ module (testcontainers#3230) feat(options): add WithProvider (testcontainers#3241) chore(deps): bump github/codeql-action from 3.29.2 to 3.29.3 (testcontainers#3237) chore(deps): bump golang.org/x/oauth2 in /modules/weaviate (testcontainers#3240) chore(deps): bump mkdocs-include-markdown-plugin from 7.1.5 to 7.1.6 (testcontainers#3239) chore(deps): bump requests from 2.32.0 to 2.32.4 (testcontainers#3204) feat(mcpgateway): add MCP gateway module (testcontainers#3232) chore(deps): bump golang.org/x/oauth2 in /modules/pulsar (testcontainers#3236) chore(deps): bump golang.org/x/oauth2 in /modules/gcloud (testcontainers#3235) ...
mdelapenya
approved these changes
Sep 5, 2025
Member
mdelapenya
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@knqyf263 thanks for this tiny fix for such a subtle bug. Much appreciated 🙇
LGTM!
mdelapenya
added a commit
to mdelapenya/testcontainers-go
that referenced
this pull request
Sep 5, 2025
* main: (30 commits) fix: preserve unix socket schema in testcontainers host from properties (testcontainers#3213) feat(registry): add helper functions to pull and tag images (testcontainers#3275) fix(reaper): remove termSignal override (testcontainers#3261) chore(deps): bump ryuk to v0.13.0, which uses scratch as base image (testcontainers#3274) chore(release): refine release script to update inter-module dependencies (testcontainers#3273) fix(registry): update `WithHtpasswd` to use `os.CreateTemp` instead of `os.Create` with `filepath.Join`. (testcontainers#3272) chore(deps): bump github.com/docker/docker from 28.2.2+incompatible to 28.3.3+incompatible (testcontainers#3270) chore(postgres): use require.NotNil instead of assert.NotNil (testcontainers#3252) fix(nats): use wait for listening port instead of wait for log (testcontainers#3256) chore(deps): bump github.com/go-viper/mapstructure/v2 (testcontainers#3267) fix(postgres): snapshot restore (testcontainers#3264) fix(dockermcpgateway): use duckduckgo instead of brave (testcontainers#3247) feat: add Solace pubsub+ module (testcontainers#3230) feat(options): add WithProvider (testcontainers#3241) chore(deps): bump github/codeql-action from 3.29.2 to 3.29.3 (testcontainers#3237) chore(deps): bump golang.org/x/oauth2 in /modules/weaviate (testcontainers#3240) chore(deps): bump mkdocs-include-markdown-plugin from 7.1.5 to 7.1.6 (testcontainers#3239) chore(deps): bump requests from 2.32.0 to 2.32.4 (testcontainers#3204) feat(mcpgateway): add MCP gateway module (testcontainers#3232) chore(deps): bump golang.org/x/oauth2 in /modules/pulsar (testcontainers#3236) ...
mdelapenya
added a commit
that referenced
this pull request
Sep 15, 2025
* main: (24 commits) chore(deps): bump golang.org/x/sys from 0.32.0 to 0.36.0 (#3282) feat(redpanda): add support for http proxy (#3258) chore(deps): bump github/codeql-action from 3.29.3 to 3.30.3 (#3287) chore(go): bump to Go 1.24 as minimal version (#3298) deps(mongodb): update MongoDB Go Driver to v2 (#3278) chore(deps): bump github.com/shirou/gopsutil/v4 from 4.25.5 to 4.25.6 (#3224) chore(deps): bump mkdocs-include-markdown-plugin from 7.1.6 to 7.1.7 (#3284) docs: clarify no client SDKs in production modules/images, in contributing.md (#3279) chore(deps): bump github.com/docker/go-connections from 0.5.0 to 0.6.0 (#3285) chore(deps): bump tj-actions/changed-files from 46.0.3 to 47.0.0 (#3283) chore(modulegen): detect missing project files after new module creation (#3281) chore(deps): bump github.com/docker/docker in /modules/nebulagraph (#3277) feat(nebulagraph): add NebulaGraph module (#3266) fix: preserve unix socket schema in testcontainers host from properties (#3213) feat(registry): add helper functions to pull and tag images (#3275) fix(reaper): remove termSignal override (#3261) chore(deps): bump ryuk to v0.13.0, which uses scratch as base image (#3274) chore(release): refine release script to update inter-module dependencies (#3273) fix(registry): update `WithHtpasswd` to use `os.CreateTemp` instead of `os.Create` with `filepath.Join`. (#3272) chore(deps): bump github.com/docker/docker from 28.2.2+incompatible to 28.3.3+incompatible (#3270) ...
mdelapenya
added a commit
to prestonvasquez/testcontainers-go
that referenced
this pull request
Sep 17, 2025
* main: (22 commits) chore(deps): bump golang.org/x/net from 0.28.0 to 0.38.0 (testcontainers#3299) feat: allow saving specific platforms for an image (testcontainers#3218) chore(deps): bump dario.cat/mergo from 1.0.1 to 1.0.2 (testcontainers#3238) chore(deps): bump golang.org/x/sys from 0.32.0 to 0.36.0 (testcontainers#3282) feat(redpanda): add support for http proxy (testcontainers#3258) chore(deps): bump github/codeql-action from 3.29.3 to 3.30.3 (testcontainers#3287) chore(go): bump to Go 1.24 as minimal version (testcontainers#3298) deps(mongodb): update MongoDB Go Driver to v2 (testcontainers#3278) chore(deps): bump github.com/shirou/gopsutil/v4 from 4.25.5 to 4.25.6 (testcontainers#3224) chore(deps): bump mkdocs-include-markdown-plugin from 7.1.6 to 7.1.7 (testcontainers#3284) docs: clarify no client SDKs in production modules/images, in contributing.md (testcontainers#3279) chore(deps): bump github.com/docker/go-connections from 0.5.0 to 0.6.0 (testcontainers#3285) chore(deps): bump tj-actions/changed-files from 46.0.3 to 47.0.0 (testcontainers#3283) chore(modulegen): detect missing project files after new module creation (testcontainers#3281) chore(deps): bump github.com/docker/docker in /modules/nebulagraph (testcontainers#3277) feat(nebulagraph): add NebulaGraph module (testcontainers#3266) fix: preserve unix socket schema in testcontainers host from properties (testcontainers#3213) feat(registry): add helper functions to pull and tag images (testcontainers#3275) fix(reaper): remove termSignal override (testcontainers#3261) chore(deps): bump ryuk to v0.13.0, which uses scratch as base image (testcontainers#3274) ...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do?
This PR fixes an issue where UNIX domain socket URLs configured in the
tc.hostproperty in~/.testcontainers.propertieswould have their schema stripped, causing Docker client initialization to fail.Changes made:
testcontainersHostFromPropertiesfunction to preserve the original URL with schema after validationTechnical details:
The function now validates the URL format using
parseURL()but returns the original URL instead of the parsed result, ensuring the Docker client receives the full URL with schema (e.g.,unix:///var/run/docker.sockinstead of just/var/run/docker.sock).Initially, I considered modifying
parseURL()to preserve the schema for UNIX sockets. However, this function is also used bydockerHostFromContextwhich expects only the path portion (without schema) for internal operations.To avoid breaking existing functionality, I chose a more targeted approach: update
testcontainersHostFromPropertiesnow.Why is it important?
When users configure UNIX domain sockets in
~/.testcontainers.propertiesusingtc.host=unix:///var/run/docker.sock, the application would panic with:This occurs because:
testcontainersHostFromPropertiescallsparseURL()which strips theunix://schemadockerHostCheckprotocol://addressformat, but receives only the pathThis fix ensures UNIX socket configurations in
~/.testcontainers.propertieswork correctly while maintaining compatibility with existing TCP host configurations.Related issues
If an issue should be created first, I'm happy to create one before merging this PR