Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker cp command not allowed

Tags:

docker

I'm trying to copy a file from a container to my host windows machine with this command

docker cp my_container:/folder c:\anotherfolder

the docker console returns

copying between containers is not supported

Why?

 Client:
 Version:      17.05.0-ce
 API version:  1.29
 Go version:   go1.7.5
 Git commit:   89658be
 Built:        Fri May  5 15:36:11 2017
 OS/Arch:      windows/amd64

Server:
 Version:      17.05.0-ce
 API version:  1.29 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   89658be
 Built:        Thu May  4 21:43:09 2017
 OS/Arch:      linux/amd64
 Experimental: false
like image 950
Thomas Fournet Avatar asked Oct 21 '17 18:10

Thomas Fournet


1 Answers

I think it's because docker thinks c is container name. You can use relative path rather than absolute path.

So if you are in C:/ you can just:

docker cp my_container:/folder anotherfolder

Also notice that there are few differences between running commands in window's cmd and in git bash.

1. You are using git bash:

Or escape in git bash console on windows:

WlaDo@DESKTOP-RBBRJOD MINGW64 ~
$ docker cp eb19fc21889c:/data c:\test
copying between containers is not supported <--- we got this error which points to implementation for which I added link below

WlaDo@DESKTOP-RBBRJOD MINGW64 ~
$ docker cp eb19fc21889c:/data c:\\test
<--- no errors here -->

WlaDo@DESKTOP-RBBRJOD MINGW64 ~
$ ls c:\\test
<--- data from container -->

2. You are using windows cmd

From windows cmd the approach you have should work:

C:\Users\WlaDo>docker cp eb19fc21889c:/data c:\test
<--- no errors here -->

C:\Users\WlaDo> dir  c:\test
<--- data from container -->

Copying between containers is not implemented and throws the error.

For more info check documentation about docker cp

A colon (:) is used as a delimiter between CONTAINER and its path. You can also use : when specifying paths to a SRC_PATH or DEST_PATH on a local machine, for example file:name.txt. If you use a : in a local machine path, you must be explicit with a relative or absolute path, for example:

`/path/to/file:name.txt` or `./file:name.txt`

like image 138
VladoDemcak Avatar answered Oct 19 '22 11:10

VladoDemcak