Skip to content

Commit 74a896f

Browse files
authored
Merge pull request #6157 from ndeloof/use_api_socket
mount /var/run/docker.sock for --use-api-socket
2 parents 7cbee73 + 2ba7cb8 commit 74a896f

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

cli/command/container/create.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,15 +248,14 @@ func createContainer(ctx context.Context, dockerCli command.Cli, containerCfg *c
248248
// 1. Mount the actual docker socket.
249249
// 2. A synthezised ~/.docker/config.json with resolved tokens.
250250

251-
socket := dockerCli.DockerEndpoint().Host
252-
if !strings.HasPrefix(socket, "unix://") {
253-
return "", fmt.Errorf("flag --use-api-socket can only be used with unix sockets: docker endpoint %s incompatible", socket)
251+
if dockerCli.ServerInfo().OSType == "windows" {
252+
return "", errors.New("flag --use-api-socket can't be used with a Windows Docker Engine")
254253
}
255-
socket = strings.TrimPrefix(socket, "unix://") // should we confirm absolute path?
256254

255+
// hard-code engine socket path until https://github.com/moby/moby/pull/43459 gives us a discovery mechanism
257256
containerCfg.HostConfig.Mounts = append(containerCfg.HostConfig.Mounts, mount.Mount{
258257
Type: mount.TypeBind,
259-
Source: socket,
258+
Source: "/var/run/docker.sock",
260259
Target: "/var/run/docker.sock",
261260
BindOptions: &mount.BindOptions{},
262261
})

0 commit comments

Comments
 (0)