From c02e5e4cb4c719d4323358efce89c45306efd04c Mon Sep 17 00:00:00 2001 From: puneetdixit200 Date: Thu, 4 Jun 2026 08:40:21 +0530 Subject: [PATCH] Fix compose command fallback for remote Docker hosts --- pkg/commands/docker.go | 6 +++++- pkg/commands/docker_test.go | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/pkg/commands/docker.go b/pkg/commands/docker.go index b055441a8..52f361a82 100644 --- a/pkg/commands/docker.go +++ b/pkg/commands/docker.go @@ -178,7 +178,11 @@ func (c *DockerCommand) setDockerComposeCommand(config *config.AppConfig) { return } - // it's possible that a user is still using docker-compose, so we'll check if 'docker comopose' is available, and if not, we'll fall back to 'docker-compose' + if os.Getenv(dockerHostEnvKey) != "" { + return + } + + // it's possible that a user is still using docker-compose, so we'll check if 'docker compose' is available, and if not, we'll fall back to 'docker-compose' err := c.OSCommand.RunCommand("docker compose version") if err != nil { config.UserConfig.CommandTemplates.DockerCompose = "docker-compose" diff --git a/pkg/commands/docker_test.go b/pkg/commands/docker_test.go index db45a06ff..4145ae2c2 100644 --- a/pkg/commands/docker_test.go +++ b/pkg/commands/docker_test.go @@ -2,6 +2,7 @@ package commands import ( "os" + "os/exec" "testing" "github.com/docker/docker/client" @@ -89,3 +90,19 @@ func TestIsProjectScoped(t *testing.T) { }) } } + +func TestSetDockerComposeCommandKeepsDefaultForRemoteDockerHost(t *testing.T) { + t.Setenv(dockerHostEnvKey, "ssh://example.com") + + userConfig := config.GetDefaultConfig() + appConfig := &config.AppConfig{UserConfig: &userConfig} + osCommand := NewOSCommand(NewDummyLog(), appConfig) + osCommand.SetCommand(func(string, ...string) *exec.Cmd { + return exec.Command("sh", "-c", "exit 1") + }) + + dockerCommand := &DockerCommand{OSCommand: osCommand} + dockerCommand.setDockerComposeCommand(appConfig) + + assert.Equal(t, "docker compose", appConfig.UserConfig.CommandTemplates.DockerCompose) +}