Copy folder with wildcard from docker container to host

Viewed 30761

Creating a backup script to dump mongodb inside a container, I need to copy the folder outside the container, Docker cp doesn't seem to work with wildcards :

docker cp mongodb:mongo_dump_* .

The following is thrown in the terminal :

Error response from daemon: lstat /var/lib/docker/aufs/mnt/SomeHash/mongo_dump_*: no such file or directory

Is there any workaround to use wildcards with cp command ?

3 Answers

I had a similar problem, and had to solve it in two steps:

$ docker exec <id> bash -c "mkdir -p /extract; cp -f /path/to/fileset* /extract"
$ docker cp <id>:/extract/. .

Today I have faced the same problem. And solved it like:

docker exec container /bin/sh -c 'tar -cf - /some/path/*' | tar -xvf -

Hope, this will help.

Related