Skip to content

Commit 3902b3b

Browse files
committed
mount /var/run/docker.sock for --use-api-socket
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
1 parent 3553aa2 commit 3902b3b

1 file changed

Lines changed: 1 addition & 8 deletions

File tree

pkg/compose/apiSocket.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package compose
1919
import (
2020
"bytes"
2121
"fmt"
22-
"strings"
2322

2423
"github.com/compose-spec/compose-go/v2/types"
2524
"github.com/docker/cli/cli/config/configfile"
@@ -41,12 +40,6 @@ func (s *composeService) useAPISocket(project *types.Project) (*types.Project, e
4140
return project, nil
4241
}
4342

44-
socket := s.dockerCli.DockerEndpoint().Host
45-
if !strings.HasPrefix(socket, "unix://") {
46-
return nil, fmt.Errorf("use_api_socket can only be used with unix sockets: docker endpoint %s is incompatible", socket)
47-
}
48-
socket = strings.TrimPrefix(socket, "unix://") // should we confirm absolute path?
49-
5043
creds, err := s.dockerCli.ConfigFile().GetAllCredentials()
5144
if err != nil {
5245
return nil, fmt.Errorf("resolving credentials failed: %w", err)
@@ -69,7 +62,7 @@ func (s *composeService) useAPISocket(project *types.Project) (*types.Project, e
6962
}
7063
service.Volumes = append(service.Volumes, types.ServiceVolumeConfig{
7164
Type: types.VolumeTypeBind,
72-
Source: socket,
65+
Source: "/var/run/docker.sock",
7366
Target: "/var/run/docker.sock",
7467
})
7568

0 commit comments

Comments
 (0)