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
10 changes: 8 additions & 2 deletions apps/cli-go/internal/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ type vectorConfig struct {
DbId string
}

func shouldMountRootDockerSocket(host string) bool {
return strings.HasSuffix(host, "/.docker/run/docker.sock") ||
strings.HasSuffix(host, "/.docker/desktop/docker.sock") ||
(strings.Contains(host, "/.colima/") && strings.HasSuffix(host, "/docker.sock")) ||
strings.HasSuffix(host, "/.colima/docker.sock")
}

var (
//go:embed templates/vector.yaml
vectorConfigEmbed string
Expand Down Expand Up @@ -424,8 +431,7 @@ EOF
case "unix":
if dindHost, err = client.ParseHostURL(client.DefaultDockerHost); err != nil {
return errors.Errorf("failed to parse default host: %w", err)
} else if strings.HasSuffix(parsed.Host, "/.docker/run/docker.sock") ||
strings.HasSuffix(parsed.Host, "/.docker/desktop/docker.sock") {
} else if shouldMountRootDockerSocket(parsed.Host) {
// Docker will not mount rootless socket directly;
// instead, specify root socket to have it handled under the hood
binds = append(binds, fmt.Sprintf("%[1]s:%[1]s:ro", dindHost.Host))
Expand Down
14 changes: 14 additions & 0 deletions apps/cli-go/internal/start/start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,20 @@ func TestStartCommand(t *testing.T) {
})
}

func TestShouldMountRootDockerSocket(t *testing.T) {
t.Run("returns true for Docker Desktop and Colima sockets", func(t *testing.T) {
assert.True(t, shouldMountRootDockerSocket("/Users/test/.docker/run/docker.sock"))
assert.True(t, shouldMountRootDockerSocket("/Users/test/.docker/desktop/docker.sock"))
assert.True(t, shouldMountRootDockerSocket("/Users/test/.colima/default/docker.sock"))
assert.True(t, shouldMountRootDockerSocket("/Users/test/.colima/local/docker.sock"))
assert.True(t, shouldMountRootDockerSocket("/Users/test/.colima/docker.sock"))
})

t.Run("returns false for directly mountable sockets", func(t *testing.T) {
assert.False(t, shouldMountRootDockerSocket("/Users/test/.orbstack/run/docker.sock"))
})
}

func TestDatabaseStart(t *testing.T) {
t.Run("starts database locally", func(t *testing.T) {
// Setup in-memory fs
Expand Down
Loading