#
Copy files from the host to the Docker container
This tutorial explains to you how to copy files from host to Docker container. Copying files from the Docker container to the host is quite similar.
A Docker container could keep files, directories as a virtual machine, and it's a regular task to copy files from the host machine to the Docker container or vice-versa.
This task is done very simple using the docker cp
command:
docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|-
docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH
Options:
--archive , -a
: Archive mode (copy all uid/gid information)--follow-link , -L
: Always follow symbol link in SRC_PATH
Here it is an example.
You can see that into the DIR1 directory there are no files:
On the host you run the docker cp
command:
And here it is the result on the target (Docker container):