#Docker: copy files and folders between a container and the local filesystem
Container technology lead to a dramatic shift in computing paradigms and it is exceptionally useful in contexts where platform independence and reproducibility are important factors. This is the case for example in Machine Learning and AI applications. Containers are at the base of ML platforms such as Michelangelo (Uber), Bighead (Airbnb), Databricks, Domino, etc.
So now you are happily running your stuff in containers and tinkering around, when you need to pull out a file from one of them for e.g., check the output of an algorithm is correct, or you need to paste a directory containing a new shiny hand-made dataset to quickly test. If this was a linux machine you could just use
scp command and call it a day, so you will be glad docker now offers its own cp-like command.
So for example let’s say we want to copy the file
output.txt that is saved in the home of a running container to our desktop for some analysis. We grub the container id using
docker ps command (in these examples b0e70cca9782) and we issue the following command:
Likewise, if we have a directory containing test images and we want to copy it in the home directory of the container to test our algorithm further we can do: