Skip to content

Commit 2bde860

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

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

cli/command/container/create.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,15 +248,13 @@ 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

257255
containerCfg.HostConfig.Mounts = append(containerCfg.HostConfig.Mounts, mount.Mount{
258256
Type: mount.TypeBind,
259-
Source: socket,
257+
Source: "/var/run/docker.sock",
260258
Target: "/var/run/docker.sock",
261259
BindOptions: &mount.BindOptions{},
262260
})

0 commit comments

Comments
 (0)