Let’s say you have a running Docker Container and you need to copy a file from it down to the host, you might need to do this while building a Docker image perhaps to see what a file that has been autogenerated looks like for example. You can do this by running the following from the host:
docker cp <containername>:/<src_path> <dst_path>
You can of course to the reverse, to copy from the host to the container with:
docker cp <src_path> <containername>:/<dst_path>
Having a look at a real example, here I had a container called “v7” where I wanted to copy the “shibboleth2.xml” file from /etc/shibboleth/ directory, so i’d use:
docker cp v7:/etc/shibboleth/shibboleth2.xml .