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
π I Built a Dropshipping Automation Pipeline β Here's What I Learned (and What I'd Do Differently)
10h ago
How I Cut My LLM API Bill by 40x: A Freelancer's Migration Story
10h ago

Mattress Firm Coupons: Save up to $600
3h ago
Google Ordered to Pay $2 Billion For Anti-Competitive Practices By Swedish Court
20h ago
The Censorship Wall: Why Every AI Companion App Ends Up Filtering You
20h ago