Copy folder with wildcard from docker container to host Copy folder with wildcard from docker container to host docker docker

Copy folder with wildcard from docker container to host


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 .


It seems there is no way yet to use wildcards with the docker cp command https://github.com/docker/docker/issues/7710.

You can create the mongo dump files into a folder inside the container and then copy the folder, as detailed on the other answer here.

If you have a large dataset and/or need to do the operation often, the best way to handle that is to use docker volumes, so you can directly access the files from the container into your host folder without using any other command: https://docs.docker.com/engine/userguide/containers/dockervolumes/