@@ -17,7 +17,6 @@ import (
17
17
"github.com/docker/cli/cli/streams"
18
18
"github.com/docker/docker/api/types/container"
19
19
"github.com/docker/docker/pkg/archive"
20
- "github.com/docker/docker/pkg/system"
21
20
units "github.com/docker/go-units"
22
21
"github.com/morikuni/aec"
23
22
"github.com/pkg/errors"
@@ -235,7 +234,7 @@ func copyFromContainer(ctx context.Context, dockerCli command.Cli, copyConfig cp
235
234
// If the destination is a symbolic link, we should follow it.
236
235
if err == nil && srcStat .Mode & os .ModeSymlink != 0 {
237
236
linkTarget := srcStat .LinkTarget
238
- if ! system . IsAbs (linkTarget ) {
237
+ if ! isAbs (linkTarget ) {
239
238
// Join with the parent directory.
240
239
srcParent , _ := archive .SplitPathDirEntry (srcPath )
241
240
linkTarget = filepath .Join (srcParent , linkTarget )
@@ -319,7 +318,7 @@ func copyToContainer(ctx context.Context, dockerCli command.Cli, copyConfig cpCo
319
318
// If the destination is a symbolic link, we should evaluate it.
320
319
if err == nil && dstStat .Mode & os .ModeSymlink != 0 {
321
320
linkTarget := dstStat .LinkTarget
322
- if ! system . IsAbs (linkTarget ) {
321
+ if ! isAbs (linkTarget ) {
323
322
// Join with the parent directory.
324
323
dstParent , _ := archive .SplitPathDirEntry (dstPath )
325
324
linkTarget = filepath .Join (dstParent , linkTarget )
@@ -434,7 +433,7 @@ func copyToContainer(ctx context.Context, dockerCli command.Cli, copyConfig cpCo
434
433
// client, a `:` could be part of an absolute Windows path, in which case it
435
434
// is immediately proceeded by a backslash.
436
435
func splitCpArg (arg string ) (ctr , path string ) {
437
- if system . IsAbs (arg ) {
436
+ if isAbs (arg ) {
438
437
// Explicit local absolute path, e.g., `C:\foo` or `/foo`.
439
438
return "" , arg
440
439
}
@@ -448,3 +447,15 @@ func splitCpArg(arg string) (ctr, path string) {
448
447
449
448
return ctr , path
450
449
}
450
+
451
+ // IsAbs is a platform-agnostic wrapper for filepath.IsAbs.
452
+ //
453
+ // On Windows, golang filepath.IsAbs does not consider a path \windows\system32
454
+ // as absolute as it doesn't start with a drive-letter/colon combination. However,
455
+ // in docker we need to verify things such as WORKDIR /windows/system32 in
456
+ // a Dockerfile (which gets translated to \windows\system32 when being processed
457
+ // by the daemon). This SHOULD be treated as absolute from a docker processing
458
+ // perspective.
459
+ func isAbs (path string ) bool {
460
+ return filepath .IsAbs (path ) || strings .HasPrefix (path , string (os .PathSeparator ))
461
+ }
0 commit comments