类似于将文件从主机复制到Docker容器,但docker cp似乎不适用于多个文件
$ docker cp data/a.txt sandbox_web_1:/usr/src/app/data/
Run Code Online (Sandbox Code Playgroud)
工作正常,但是
$ docker cp data/*txt sandbox_web_1:/usr/src/app/data/
docker: "cp" requires 2 arguments.
See 'docker cp --help'.
Usage: docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|-
docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH
Copy files/folders between a container and the local filesystem
Use '-' as the source to read a tar archive from stdin
and extract it to a directory destination in a container.
Use '-' as the destination to stream a tar archive of a
container source to stdout.
Run Code Online (Sandbox Code Playgroud)
在Ubuntu 14.04x64上使用docker 1.11.1
Von*_*onC 15
有一项支持通配符的建议docker cp(7710),但尚未实施.
这样就可docker cp以为每个文件使用bash脚本了:
for f in data/*txt; do docker cp $f sandbox_web_1:/usr/src/app/data/; done
Run Code Online (Sandbox Code Playgroud)
小智 9
以下命令应将整个目录数据及其数据目录的内容复制到所需的目标:
docker cp data/ sandbox_web_1:/usr/src/app/
Run Code Online (Sandbox Code Playgroud)
在Docker版本1.12.1上测试,但我没有在1.12.1版本中找到对cp命令的任何更改
| 归档时间: |
|
| 查看次数: |
11504 次 |
| 最近记录: |