dockercopy

Copy multiple local files to docker container


Similar to Copying files from host to Docker container, except docker cp doesn't seem to work for multiple files

$ docker cp data/a.txt sandbox_web_1:/usr/src/app/data/

works fine, but

$ 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.

Using docker 1.11.1 on Ubuntu 14.04x64


Solution

  • There is a proposal for docker cp to support wildcards (7710), but it is not implemented yet.

    So that leaves you with bash scripting, using docker cp for each file:

    for f in data/*txt; do docker cp $f sandbox_web_1:/usr/src/app/data/; done