不允许使用Docker cp命令

我试图从一个容器中的文件复制到我的主机Windows机器与此命令

docker cp my_container:/folder c:\anotherfolder 

docker控制台返回

 copying between containers is not supported 

为什么?

客户端:版本:17.05.0-ce API版本:1.29 Go版本:go1.7.5 Git commit:89658be内置:五月5日15:36:11 OS / Arch:windows / amd64

服务器:版本:17.05.0-ce API版本:1.29(最低版本1.12)Go版本:go1.7.5 Git commit:89658be内置:Thu May 4 21:43:09 2017 OS / Arch:linux / amd64实验:false

我认为这是因为docker认为c是容器名称。 您可以使用相对path而不是绝对path。

所以如果你在C:/你可以:

 docker cp my_container:/folder anotherfolder 

另外请注意,在窗口的cmdgit bash运行命令之间几乎没有区别。

1.你正在使用git bash:

或在Windows上的git bash控制台中逃脱:

 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.您正在使用Windows cmd

从Windows cmd的方法你应该工作:

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

容器之间的复制没有实现并引发错误。

有关更多信息,请查看有关docker cp的文档

冒号(:)用作CONTAINER与其path之间的分隔符。 在本地机器上指定到SRC_PATH或DEST_PATH的path时,也可以使用:例如file:name.txt。 如果在本地机器path中使用a :,则必须显式使用相对path或绝对path,例如:

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