Skip to content

Commit 49f1d34

Browse files
committed
Skip Docker socket bind for Colima/OrbStack
1 parent 9925dae commit 49f1d34

3 files changed

Lines changed: 38 additions & 5 deletions

File tree

internal/runtime/docker.go

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

66+
// SocketPath returns the Unix socket path used by the Docker client.
67+
// Returns the actual path for the standard /var/run/docker.sock so callers
68+
// can bind-mount it into containers. Returns empty string for non-standard
69+
// sockets (Colima, OrbStack) which communicate with VMs and cannot be
70+
// bind-mounted. Called by internal/container/start.go to decide whether
71+
// to add a Docker socket bind-mount when starting LocalStack.
6672
func (d *DockerRuntime) SocketPath() string {
6773
host := d.client.DaemonHost()
6874
if strings.HasPrefix(host, "unix://") {
69-
return strings.TrimPrefix(host, "unix://")
75+
sock := strings.TrimPrefix(host, "unix://")
76+
// Skip bind-mount for non-standard sockets (Colima, OrbStack, etc.)
77+
// These sockets communicate with VMs and cannot be bind-mounted
78+
if sock != "/var/run/docker.sock" {
79+
return ""
80+
}
81+
return sock
7082
}
7183
return ""
7284
}

internal/runtime/docker_test.go

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,26 @@ 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+
})
49+
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+
})
4656

47-
assert.Equal(t, "/home/user/.colima/default/docker.sock", rt.SocketPath())
57+
t.Run("orbstack socket returns empty", func(t *testing.T) {
58+
cli, err := client.NewClientWithOpts(client.WithHost("unix:///Users/user/.orbstack/run/docker.sock"))
59+
require.NoError(t, err)
60+
rt := &DockerRuntime{client: cli}
61+
assert.Equal(t, "", rt.SocketPath(), "non-standard sockets should return empty to skip bind-mount")
62+
})
4863
}
4964

5065
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)