-
-
Notifications
You must be signed in to change notification settings - Fork 479
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
[Bug]: docker.host parameter doesn't work anymore #1338
Comments
Hi @also1366 thanks for opening this bug report. I'm adding this unit test to the t.Run("Unix Docker Host is passed as docker.host", func(t *testing.T) {
content := "docker.host=" + DockerSocketSchema + "/this/is/a/sample.sock"
setupTestcontainersProperties(t, content)
host := extractDockerHost(context.Background())
assert.Equal(t, DockerSocketSchema + "/this/is/a/sample.sock", host)
}) I'm taking a look at how Java does this: https://java.testcontainers.org/features/configuration/#customizing-docker-host-detection, and I think we have to fix the // dockerHostFromProperties returns the docker host from the ~/.testcontainers.properties file, if it's not empty
func dockerHostFromProperties(ctx context.Context) (string, error) {
cfg := config.Read()
socketPath := cfg.Host
if socketPath != "" {
- parsed, err := parseURL(socketPath)
- if err != nil {
- return "", err
- }
-
- return parsed, nil
+ return socketPath, nil
}
return "", ErrDockerSocketNotSetInProperties
} I'm checking with the other maintainers internally, but it feels that we should change this as shown above. Will ping you back |
@also1366 we merged the PR so if you are able to check the latest commit from main, it should be fixed Thanks! |
Testcontainers version
0.21.0
Using the latest Testcontainers version?
Yes
Host OS
Linux
Host arch
x86
Go version
1.20
Docker version
Docker info
What happened?
I have a
.testcontainers.properties
file in my home directory:docker.host=unix:///var/run/user/1000/docker.sock
The library reads the docker host and strips "unix://" part.
Then it provides the host "/var/run/user/1000/docker.sock" to the docker library.
Though the docker library expects the host to start with "unix://" and throws an error.
It works fine for me in version 0.20.1
When I run the test with the env variable
DOCKER_HOST=unix:///var/run/user/1000/docker.sock
it works.It doesn't strip "unix://".
I read this PR that behaviour somewhat changed, but I don't understand what's happening.
#1161
Am I doing something wrong?
Relevant log output
=== RUN TestContainers/TestElasticsearch Testcontainers properties file has been found: /home/user/.testcontainers.properties main_test.go:37: failed to start container: unable to parse docker host `/var/run/user/1000/docker.sock`, failed to create Docker provider
Additional information
No response
The text was updated successfully, but these errors were encountered: