For copying the files from the host to the docker container :
Step1: List out the container,
$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
74a4b83f1bb7 wordpress:latest "docker-entrypoint.s…" 26 seconds ago Up 24 seconds 0.0.0.0:31010->80/tcp, :::31010->80/tcp thelinuxfaq_1
First, we have to set the path in our localhost to where the file is stored in a docker container,
Next set the path in our docker container to where we want to store the file inside our docker container, here the container name is thelinuxfaq_1.
Then copy the file which we want to store in our docker container with the help of CP command or you're able to get the details using the command below,
$ docker --help
cp Copy files/folders between a container and the local filesystem
Syntax:
docker cp [Local_file] [CONTAINER_NAME]:[DESTINATION]
$ docker cp /home/user/newfile.txt thelinuxfaq_1:/app/newfile.txt
For copying Files from docker container to your host:
We can use the same "CP" option in docker,
Syntax:
docker cp [CONTAINER_NAME]:[SOURCE_FILE] [Local_Host]
$ docker cp thelinuxfaq_1:/app/newfile.txt /home/user/newfile.txt
Comments (0)