@@ -18,15 +18,17 @@ package libdocker
18
18
19
19
import (
20
20
"fmt"
21
+ "path/filepath"
21
22
"runtime"
22
23
"strconv"
23
24
"strings"
24
25
"time"
25
26
27
+ "github.com/docker/go-connections/nat"
28
+
26
29
dockerref "github.com/docker/distribution/reference"
27
30
dockertypes "github.com/docker/docker/api/types"
28
31
dockermount "github.com/docker/docker/api/types/mount"
29
- "github.com/docker/go-connections/nat"
30
32
godigest "github.com/opencontainers/go-digest"
31
33
"github.com/sirupsen/logrus"
32
34
v1 "k8s.io/cri-api/pkg/apis/runtime/v1"
@@ -217,14 +219,26 @@ func GenerateMountBindings(mounts []*v1.Mount, terminationMessagePath string, rt
217
219
}
218
220
result := make ([]dockermount.Mount , 0 , len (mounts ))
219
221
for _ , m := range mounts {
220
- if runtime .GOOS == "windows" && isSingleFileMount (m .HostPath , m .ContainerPath , terminationMessagePath ) {
221
- logrus .Debugf ("skipping mount :%s:%s" , m .HostPath , m .ContainerPath )
222
- continue
222
+ hostPath , containerPath := m .HostPath , m .ContainerPath
223
+ if runtime .GOOS == "windows" {
224
+ if isSingleFileMount (hostPath , containerPath , terminationMessagePath ) {
225
+ logrus .Debugf ("skipping mount :%s:%s" , m .HostPath , m .ContainerPath )
226
+ continue
227
+ }
228
+ if ! isNamedPipe (hostPath ) {
229
+ hostPath = filepath .Clean (hostPath )
230
+ }
231
+ if ! isNamedPipe (containerPath ) {
232
+ containerPath = filepath .Clean (containerPath )
233
+ if containerPath [0 ] == '\\' {
234
+ containerPath = "C:" + containerPath
235
+ }
236
+ }
223
237
}
224
238
bind := dockermount.Mount {
225
239
Type : dockermount .TypeBind ,
226
- Source : m . HostPath ,
227
- Target : m . ContainerPath ,
240
+ Source : hostPath ,
241
+ Target : containerPath ,
228
242
BindOptions : & dockermount.BindOptions {
229
243
CreateMountpoint : true ,
230
244
},
@@ -334,3 +348,7 @@ func MakePortsAndBindings(
334
348
}
335
349
return exposedPorts , portBindings
336
350
}
351
+
352
+ func isNamedPipe (s string ) bool {
353
+ return strings .HasPrefix (s , `\\.\pipe\` )
354
+ }
0 commit comments