Fetching latest headlines…
How to copy files from a docker container to host
NORTH AMERICA
🇺🇸 United StatesJuly 4, 2026

How to copy files from a docker container to host

0 views0 likes0 comments
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!

Comments (0)

Sign in to join the discussion

Be the first to comment!