shantanuo
shantanuo

Reputation: 32304

Copy a directory from container to host

I have saved a folder called "ec2-user" in an image. And I can easily extract one of the files...

docker run  -it shantanuo/bkup sh

docker exec -it e7611fc860a6 sh -c " cat /tmp/ec2-user/t1.txt" > t1.txt

This works as expected. But I do not know how to copy the entire directory "ec2-user" that is around 8 GB

In other words I am using docker as backup device. This is different that application deployment, but I will like to know if this is OK.

Upvotes: 3

Views: 1224

Answers (1)

Samuel Toh
Samuel Toh

Reputation: 19308

Looking at the name of your file and its size (8GB) I guess you're doing a database backup?

Since you want to copy the entire directory and it is relatively big, why not consider compressing the backup directory to a single file and then just do

docker cp my_container:/tmp/bkup/abc.xz .

To compress your backup you can use the xz utility.

Example: shantanuo/bkup | xz -8 > /tmp/bkup.xz

Upvotes: 3

Related Questions