Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy multiple local files to docker container

Tags:

docker

copy

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

like image 366
kampta Avatar asked May 11 '16 05:05

kampta


People also ask

How do I copy multiple files from Docker container to local machine?

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.


1 Answers

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 
like image 72
VonC Avatar answered Sep 22 '22 03:09

VonC