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 Files 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 Files 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/