mirror of
https://github.com/docker/compose.git
synced 2025-07-28 16:14:06 +02:00
mount /var/run/docker.sock for --use-api-socket
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
7c999d7f93
commit
51acc58453
@ -18,8 +18,8 @@ package compose
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/compose-spec/compose-go/v2/types"
|
"github.com/compose-spec/compose-go/v2/types"
|
||||||
"github.com/docker/cli/cli/config/configfile"
|
"github.com/docker/cli/cli/config/configfile"
|
||||||
@ -41,11 +41,9 @@ func (s *composeService) useAPISocket(project *types.Project) (*types.Project, e
|
|||||||
return project, nil
|
return project, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
socket := s.dockerCli.DockerEndpoint().Host
|
if s.dockerCli.ServerInfo().OSType == "windows" {
|
||||||
if !strings.HasPrefix(socket, "unix://") {
|
return nil, errors.New("use_api_socket can't be used with a Windows Docker Engine")
|
||||||
return nil, fmt.Errorf("use_api_socket can only be used with unix sockets: docker endpoint %s is incompatible", socket)
|
|
||||||
}
|
}
|
||||||
socket = strings.TrimPrefix(socket, "unix://") // should we confirm absolute path?
|
|
||||||
|
|
||||||
creds, err := s.dockerCli.ConfigFile().GetAllCredentials()
|
creds, err := s.dockerCli.ConfigFile().GetAllCredentials()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -69,7 +67,7 @@ func (s *composeService) useAPISocket(project *types.Project) (*types.Project, e
|
|||||||
}
|
}
|
||||||
service.Volumes = append(service.Volumes, types.ServiceVolumeConfig{
|
service.Volumes = append(service.Volumes, types.ServiceVolumeConfig{
|
||||||
Type: types.VolumeTypeBind,
|
Type: types.VolumeTypeBind,
|
||||||
Source: socket,
|
Source: "/var/run/docker.sock",
|
||||||
Target: "/var/run/docker.sock",
|
Target: "/var/run/docker.sock",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user