Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with docker cp on windows when copying directory content to an existing directory #34638

Open
xialian opened this issue Aug 25, 2017 · 3 comments

Comments

@xialian
Copy link

xialian commented Aug 25, 2017

Description
According to official docker documentation, docker cp src_path dest_path should support the following behavior: When src_path specifies and directory and ends with /. (for windows, \.), and the dest_path specifies an existing directory, the content of src_path (files and sub-directories) should be copied into dest_path. However, docker on windows gives an error instead in this case.

Steps to reproduce the issue:

  1. On host machine: docker run -it --name test_container microsoft/nanoserver
  2. Within the launched container: Create the the following directory and file C:\test_dir\test.txt, and then exit the container
  3. On host machine: mkdir docker_test
  4. On host machine: docker cp test_container:C:\test_dir\. .\docker_test

Describe the results you received:

Error response from daemon: GetFileAttributesEx \\?\Volume{71a5bce9-587d-4726-84a6-83f9c99ea9c7}\test_dir\.: The filename, directory name, or volume label syntax is incorrect

Describe the results you expected:
test.txt file should appear in .\docker_test on host machine

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker version:

Client:
 Version:      17.06.1-ce
 API version:  1.30
 Go version:   go1.8.3
 Git commit:   874a737
 Built:        Thu Aug 17 22:48:20 2017
 OS/Arch:      windows/amd64

Server:
 Version:      17.06.1-ce
 API version:  1.30 (minimum version 1.24)
 Go version:   go1.8.3
 Git commit:   874a737
 Built:        Thu Aug 17 23:03:03 2017
 OS/Arch:      windows/amd64
 Experimental: true

Output of docker info:

Containers: 2
 Running: 0
 Paused: 0
 Stopped: 2
Images: 4
Server Version: 17.06.1-ce
Storage Driver: windowsfilter
 Windows:
Logging Driver: json-file
Plugins:
 Volume: local
 Network: l2bridge l2tunnel nat null overlay transparent
 Log: awslogs etwlogs fluentd json-file logentries splunk syslog
Swarm: inactive
Default Isolation: hyperv
Kernel Version: 10.0 15063 (15063.0.amd64fre.rs2_release.170317-1834)
Operating System: Windows 10 Enterprise
OSType: windows
Architecture: x86_64
CPUs: 40
Total Memory: 31.92GiB
Name: xialian
ID: QZQC:GOOJ:GUWZ:HQLE:5F5J:X6IA:TRQX:Z7JA:3TYR:VWQJ:U66K:HMMH
Docker Root Dir: C:\ProgramData\Docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: -1
 Goroutines: 22
 System Time: 2017-08-25T11:43:05.89398-07:00
 EventsListeners: 0
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
 10.120.64.57:5500
 10.120.66.6:5000
 127.0.0.0/8
Live Restore Enabled: false

Additional information:
I have also tried with various other kinds of src_path endings, including \, \*. None of them can correctly produce the behavior of copying content of a container directory (not the directory itself) to an existing host directory.
This issue is filed after discussion with @jhowardmsft.
@darrenstahlmsft @johnstep

@taha
Copy link

taha commented Sep 13, 2017

I'm experiencing the same issue. Any update on this?

@Jeff-Lewis
Copy link

We're just missing the last case (bold) as defined by Docker's documentation for Windows.

Assuming a path separator of /, a first argument of SRC_PATH and second argument of DEST_PATH, the behavior is as follows:

  • SRC_PATH specifies a file
    • DEST_PATH does not exist
      • the file is saved to a file created at DEST_PATH
    • DEST_PATH does not exist and ends with /
      • Error condition: the destination directory must exist.
    • DEST_PATH exists and is a file
      • the destination is overwritten with the source file’s contents
    • DEST_PATH exists and is a directory
      • the file is copied into this directory using the basename from SRC_PATH
  • SRC_PATH specifies a directory
    • DEST_PATH does not exist
      • DEST_PATH is created as a directory and the contents of the source directory are copied into this directory
    • DEST_PATH exists and is a file
      • Error condition: cannot copy a directory to a file
    • DEST_PATH exists and is a directory
      • SRC_PATH does not end with /. (that is: slash followed by dot)
        • the source directory is copied into this directory
      • SRC_PATH does end with /. (that is: slash followed by dot)
        • the content of the source directory is copied into this directory

@thaJeztah
Copy link
Member

@jhowardmsft @johnstep ptal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants