It may sound trivial but I couldn't find a easy way to copy multiple files into the root folder of a docker volume. I am using Ubuntu Xenial 16.04 and Docker 1.12.1. For example if I have an Ubuntu container with the volume /my_data:
docker run --name my_container -v /my_data -d ubuntu:latest
In my host machine I have a folder called /tmp/my_data/ with multiple files inside, and I would like to copy all those files into the volume /my_data in my_container. I have tried the following approaches but none of them work:
docker cp /tmp/my_data my_container:/
docker cp /tmp/my_data/* my_container:/my_data/
Does someone know a work around for this issue?
Actually it was easier than I though, just need to add a dot in the host path and it will work as expected, copying all files and folders within /my_data folder
docker cp /tmp/my_data/. my_container:/my_data
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With