Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions internal/core/docker_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,14 @@ func testcontainersHostFromProperties(_ context.Context) (string, error) {
cfg := config.Read()
testcontainersHost := cfg.TestcontainersHost
if testcontainersHost != "" {
parsed, err := parseURL(testcontainersHost)
// Validate the URL format
_, err := parseURL(testcontainersHost)
if err != nil {
return "", err
}

return parsed, nil
// Return the original URL to preserve schema for Docker client
return testcontainersHost, nil
}

return "", ErrTestcontainersHostNotSetInProperties
Expand Down
23 changes: 18 additions & 5 deletions internal/core/docker_host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,26 @@ func TestExtractDockerHost(t *testing.T) {
t.Cleanup(resetSocketOverrideFn)

t.Run("Testcontainers host is defined in properties", func(t *testing.T) {
content := "tc.host=" + testRemoteHost
t.Run("TCP host", func(t *testing.T) {
content := "tc.host=" + testRemoteHost

setupTestcontainersProperties(t, content)
setupTestcontainersProperties(t, content)

socket, err := testcontainersHostFromProperties(context.Background())
require.NoError(t, err)
require.Equal(t, testRemoteHost, socket)
socket, err := testcontainersHostFromProperties(context.Background())
require.NoError(t, err)
require.Equal(t, testRemoteHost, socket)
})

t.Run("Unix socket host preserves schema", func(t *testing.T) {
unixSocket := "unix:///var/run/docker.sock"
content := "tc.host=" + unixSocket

setupTestcontainersProperties(t, content)

socket, err := testcontainersHostFromProperties(context.Background())
require.NoError(t, err)
require.Equal(t, unixSocket, socket)
})
})

t.Run("Testcontainers host is not defined in properties", func(t *testing.T) {
Expand Down
Loading