How to Copy Files from Docker Container to Host

How to Copy Files from Docker Container to Host

Today in this article, we will see how to Copy Files from Docker Container to Host.

This technique is also useful if containers are stopped or paused as well.

Command

docker cp <container>:<container-source-path> <destination-path>

The docker cp the utility copies the contents of the Source Container to the target path specified.

You can copy from the container’s file system to the local machine or vice versa.

Below we are copying the file from the container to the host path.

Once copied, the host path can be used to explore the files.


Example

Below command is executed on windows,

docker cp 1cf2eafdee49:app test\docker-dump

copy Files from Docker Container to Host

Below is now how you can check all the files and directory

dir path

Copy Files from Docker Container to Host

References:

Do you have any comments or ideas or any better suggestions to share?

Please sound off your comments below.

Happy Coding !!



Please bookmark this page and share it with your friends. Please Subscribe to the blog to receive notifications on freshly published(2024) best practices and guidelines for software design and development.



Leave a Reply

Your email address will not be published. Required fields are marked *