How to copy files from a Docker container to the host

You can copy files from a Docker container to the host even if you didn't mount a volume using the command docker cp.

Here's an example where we copy the file /home/user/file.jpg from the container to file.jpg in the current dicretory of the host:

$ docker cp my_container:/home/user/file.jpg file.jpg
1 email / week to learn how to (ab)use technology for fun & profit: Programming, Hacking & Entrepreneurship.
I hate spam even more than you do. I'll never share your email, and you can unsubscribe at any time.

Tags: programming, devops

Want to learn Rust, Cryptography and Security? Get my book Black Hat Rust!