From 51acc5845329f81b329962126102835af3e2b25a Mon Sep 17 00:00:00 2001 From: Nicolas De Loof Date: Mon, 30 Jun 2025 12:04:01 +0200 Subject: [PATCH] mount /var/run/docker.sock for --use-api-socket Signed-off-by: Nicolas De Loof --- pkg/compose/apiSocket.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pkg/compose/apiSocket.go b/pkg/compose/apiSocket.go index 6b8c8ba53..4bd2aabea 100644 --- a/pkg/compose/apiSocket.go +++ b/pkg/compose/apiSocket.go @@ -18,8 +18,8 @@ package compose import ( "bytes" + "errors" "fmt" - "strings" "github.com/compose-spec/compose-go/v2/types" "github.com/docker/cli/cli/config/configfile" @@ -41,11 +41,9 @@ func (s *composeService) useAPISocket(project *types.Project) (*types.Project, e return project, nil } - socket := s.dockerCli.DockerEndpoint().Host - if !strings.HasPrefix(socket, "unix://") { - return nil, fmt.Errorf("use_api_socket can only be used with unix sockets: docker endpoint %s is incompatible", socket) + if s.dockerCli.ServerInfo().OSType == "windows" { + return nil, errors.New("use_api_socket can't be used with a Windows Docker Engine") } - socket = strings.TrimPrefix(socket, "unix://") // should we confirm absolute path? creds, err := s.dockerCli.ConfigFile().GetAllCredentials() if err != nil { @@ -69,7 +67,7 @@ func (s *composeService) useAPISocket(project *types.Project) (*types.Project, e } service.Volumes = append(service.Volumes, types.ServiceVolumeConfig{ Type: types.VolumeTypeBind, - Source: socket, + Source: "/var/run/docker.sock", Target: "/var/run/docker.sock", })