Skip to main content
Code and think

Docker Copy file from/to container

The cp command can be used to copy files. One specific file (foo.txt) can be copied to the container like: docker cp foo.txt mycontainer:/foo.txt One specific file (foo.txt) can be copied from the container like: docker cp mycontainer:/foo.txt foo.txt For emphasis, mycontainer is a container ID, not an image ID.

Multiple files contained by the folder src can be copied into the target folder using: docker cp src/. mycontainer:/target docker cp mycontainer:/src/. target

Reference