The cp
command can be used to copy files.
(cp
命令可用于复制文件。)
One specific file can be copied TO the container like:
(可以将一个特定文件复制到容器中,例如:)
docker cp foo.txt mycontainer:/foo.txt
One specific file can be copied FROM the container like:
(可以从容器中复制一个特定文件,例如:)
docker cp mycontainer:/foo.txt foo.txt
For emphasis, mycontainer
is a container ID, not an image ID.
(为了强调, mycontainer
是容器 ID, 而不是 图像 ID。)
Multiple files contained by the folder src
can be copied into the target
folder using:
(可以使用以下命令将文件夹src
包含的多个文件复制到target
文件夹中:)
docker cp src/. mycontainer:/target
docker cp mycontainer:/src/. target
Reference: Docker CLI docs for cp
(参考: 适用于cp
Docker CLI文档)
In Docker versions prior to 1.8 it was only possible to copy files from a container to the host.
(在1.8之前的Docker版本中,只能将文件从容器复制到主机。)
Not from the host to a container. (不是从主机到容器。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…