@@ -31,7 +31,6 @@ import (
3131 "github.com/docker/cli/cli/command"
3232 "github.com/docker/compose/v2/pkg/api"
3333 "github.com/docker/docker/api/types/container"
34- "github.com/docker/docker/pkg/system"
3534 "github.com/moby/go-archive"
3635)
3736
@@ -161,7 +160,7 @@ func (s *composeService) copyToContainer(ctx context.Context, containerID string
161160 // If the destination is a symbolic link, we should evaluate it.
162161 if err == nil && dstStat .Mode & os .ModeSymlink != 0 {
163162 linkTarget := dstStat .LinkTarget
164- if ! system . IsAbs (linkTarget ) {
163+ if ! isAbs (linkTarget ) {
165164 // Join with the parent directory.
166165 dstParent , _ := archive .SplitPathDirEntry (dstPath )
167166 linkTarget = filepath .Join (dstParent , linkTarget )
@@ -264,7 +263,7 @@ func (s *composeService) copyFromContainer(ctx context.Context, containerID, src
264263 // If the destination is a symbolic link, we should follow it.
265264 if err == nil && srcStat .Mode & os .ModeSymlink != 0 {
266265 linkTarget := srcStat .LinkTarget
267- if ! system . IsAbs (linkTarget ) {
266+ if ! isAbs (linkTarget ) {
268267 // Join with the parent directory.
269268 srcParent , _ := archive .SplitPathDirEntry (srcPath )
270269 linkTarget = filepath .Join (srcParent , linkTarget )
@@ -302,8 +301,20 @@ func (s *composeService) copyFromContainer(ctx context.Context, containerID, src
302301 return archive .CopyTo (preArchive , srcInfo , dstPath )
303302}
304303
304+ // IsAbs is a platform-agnostic wrapper for filepath.IsAbs.
305+ //
306+ // On Windows, golang filepath.IsAbs does not consider a path \windows\system32
307+ // as absolute as it doesn't start with a drive-letter/colon combination. However,
308+ // in docker we need to verify things such as WORKDIR /windows/system32 in
309+ // a Dockerfile (which gets translated to \windows\system32 when being processed
310+ // by the daemon). This SHOULD be treated as absolute from a docker processing
311+ // perspective.
312+ func isAbs (path string ) bool {
313+ return filepath .IsAbs (path ) || strings .HasPrefix (path , string (os .PathSeparator ))
314+ }
315+
305316func splitCpArg (arg string ) (ctr , path string ) {
306- if system . IsAbs (arg ) {
317+ if isAbs (arg ) {
307318 // Explicit local absolute path, e.g., `C:\foo` or `/foo`.
308319 return "" , arg
309320 }
0 commit comments