Skip to content

Commit ea31bd9

Browse files
committed
Skip Docker socket bind for Colima and OrbStack
1 parent 9925dae commit ea31bd9

3 files changed

Lines changed: 29 additions & 5 deletions

File tree

internal/runtime/docker.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,20 @@ func probeSocket(candidates ...string) string {
6363
return ""
6464
}
6565

66+
// SocketPath returns the Unix socket path used by the Docker client.
67+
// Returns empty string for standard /var/run/docker.sock to indicate
68+
// the socket can be bind-mounted. Returns the actual path for alternative
69+
// sockets (Colima, OrbStack) which cannot be bind-mounted into containers.
6670
func (d *DockerRuntime) SocketPath() string {
6771
host := d.client.DaemonHost()
6872
if strings.HasPrefix(host, "unix://") {
69-
return strings.TrimPrefix(host, "unix://")
73+
sock := strings.TrimPrefix(host, "unix://")
74+
// Skip bind-mount for non-standard sockets (Colima, OrbStack, etc.)
75+
// These sockets communicate with VMs and cannot be bind-mounted
76+
if sock != "/var/run/docker.sock" {
77+
return ""
78+
}
79+
return sock
7080
}
7181
return ""
7282
}

internal/runtime/docker_test.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,19 @@ func TestProbeSocket_ReturnsEmptyForNoCandidates(t *testing.T) {
4040
}
4141

4242
func TestSocketPath_ExtractsUnixPath(t *testing.T) {
43-
cli, err := client.NewClientWithOpts(client.WithHost("unix:///home/user/.colima/default/docker.sock"))
44-
require.NoError(t, err)
45-
rt := &DockerRuntime{client: cli}
43+
t.Run("standard socket returns path", func(t *testing.T) {
44+
cli, err := client.NewClientWithOpts(client.WithHost("unix:///var/run/docker.sock"))
45+
require.NoError(t, err)
46+
rt := &DockerRuntime{client: cli}
47+
assert.Equal(t, "/var/run/docker.sock", rt.SocketPath())
48+
})
4649

47-
assert.Equal(t, "/home/user/.colima/default/docker.sock", rt.SocketPath())
50+
t.Run("non-standard socket returns empty", func(t *testing.T) {
51+
cli, err := client.NewClientWithOpts(client.WithHost("unix:///home/user/.colima/default/docker.sock"))
52+
require.NoError(t, err)
53+
rt := &DockerRuntime{client: cli}
54+
assert.Equal(t, "", rt.SocketPath(), "non-standard sockets should return empty to skip bind-mount")
55+
})
4856
}
4957

5058
func TestSocketPath_ReturnsEmptyForTCPHost(t *testing.T) {

test/integration/start_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,12 @@ func TestStartCommandSetsUpContainerCorrectly(t *testing.T) {
168168
t.Skip("Docker daemon is not reachable via unix socket")
169169
}
170170

171+
// Skip bind-mount assertion for non-standard sockets (Colima, OrbStack)
172+
// since these communicate with VMs and cannot be bind-mounted
173+
if dockerClient.DaemonHost() != "unix:///var/run/docker.sock" {
174+
t.Skip("Docker daemon uses non-standard socket (Colima/OrbStack) - socket not bind-mounted")
175+
}
176+
171177
assert.True(t, hasBindTarget(inspect.HostConfig.Binds, "/var/run/docker.sock"),
172178
"expected Docker socket bind mount to /var/run/docker.sock, got: %v", inspect.HostConfig.Binds)
173179

0 commit comments

Comments
 (0)