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 ?
You can create the mongo dump files into a folder inside the container and then copy the folder: this is a workaround.
It seems there is no way yet to use wildcards with the docker cp command https://github.com/docker/docker/issues/7710.
I think the best way to handle what you want to do is to use docker volumes, so you can directly save the files from the container into your host folder without using any other command: https://docs.docker.com/engine/userguide/containers/dockervolumes/
I had a similar problem, and had to solve it in two steps:
$ docker exec <id> bash -c "mkdir /extract; mv /path/to/fileset* /extract"
$ docker cp <id>:/extract .