Skip to content
Merged
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: 4 additions & 6 deletions pkg/compose/apiSocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand All @@ -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",
})

Expand Down