Originally published byDev.to
How to copy files from a docker container to host
Sometimes we just want to know the content of a generated file into some container. And this is the way to do:
First of all, make sure the data you want to copy is in container:
docker exec -it <container reference> /bin/bash
I strongly suggest you to use /bin/bash instead of sh because sh lacks lots of useful features, like autocomplete, command history.
Then, assured what you need is there, just do it almost like a normal copy:
sudo docker cp -a <container reference>:<container path> <host path>
Example:
sudo docker cp -a 3bbef5e21df:/home/fls/ .
The difference is an ‘-a’ flag which means archive mode. It’ll help you copying with GID|UID information.
That’s all for now.
Thanks for reading!
🇺🇸
More news from United StatesUnited States
NORTH AMERICA
Related News
Secret Claude Tracker Shocks Users After Anthropic's Anti-Surveillance Stance
12h ago
EV Batteries Defy Expectations, Last Hundreds of Thousands of Miles
1d ago
GBase 8a Performance Anomaly Case Study: How a Single Parameter Change Sparked a Chain Reaction
1d ago
Who Else Has Inherited a Codebase With Zero Comments and a Prayer?
1d ago
完美的平庸
4h ago