Docker cp command
Docker cp command is used to copy files between docker host system and container machine. This will work even the docker container is not running.
docker cp [OPTIONS] SRC_PATH DEST_PATH
Copy File from Container to Host
Copy a file /opt/testfile.txt from container id 043869c58300 to host machine /tmp directory. use following example.
$ docker cp 043869c58300:/opt/testfile.txt /tmp
You can also use container name instead of container ID.
Copy File from Host to Container
Also, copy a file /opt/newfile.txt from host system to container ( id 043869c58300) /opt directory. use following example.
$ docker cp /opt/newfile.txt 043869c58300:/opt/