类似于 Copying files from host to Docker container ,除了 docker cp
似乎不适用于多个文件
$ docker cp data/a.txt sandbox_web_1:/usr/src/app/data/
工作正常,但是
$ 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.
在 Ubuntu 14.04x64 上使用 docker 1.11.1
最佳答案
有一个proposal for docker cp
to support wildcards (7710) ,但尚未实现。
这样就剩下 bash 脚本了,使用 docker cp
对于每个文件:
for f in data/*txt; do docker cp $f sandbox_web_1:/usr/src/app/data/; done
关于docker - 将多个本地文件复制到 docker 容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37153857/