user3001829
user3001829

Reputation: 25962

Taking files off a docker container

Is it possible to pull files off a docker container onto the local host?

I want to take certain directories off the docker containers I have worked on and move them to the local host on a daily basis.

Is this possible and how can it be done?

Upvotes: 3

Views: 310

Answers (2)

abronan
abronan

Reputation: 3439

Yes you can, simply use the docker cp command.

An example from the official CLI documentation :

sudo docker cp <container-id>:/etc/hosts .

Upvotes: 4

Reza S
Reza S

Reputation: 9748

May I ask what's the reason you want to copy these files out of the container? If it's a one off thing then you're better off copying them as @abronan suggested, but if these directories are something that you'll be copying out and copying back into another container or the same container next time, you might want to look at volumes that enable you to have persistent data in your container as well as between containers

Upvotes: 1

Related Questions