If you want to copy data from the docker host in a running container, So it can be done with ‘cp‘ command in docker. You can copy the folder and file it in the container. you don’t need to find a docker copy file from where. you can also copy the files in a stopped container and put them later once the container up and running.
Check Out: How To Create Container In Docker-CE
Copy Data From Docker Host In Running:
You do not need to worry about if you forgot the copy data during creating an image. This is a simple command to achieve the task without stopping the container and you don’t need to log in the container as well.
Check Out: Signup For Docker Hub
Docker Copy Format :
docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH
Suppose I want to copy vhost.conf which is created at root partition. Now I want to copy this file to a running container from outside the container.
Check Out: Create Apache Image Using Dockerfile
docker cp /root/vhost.conf b9947aefe406:/etc/httpd/
Access the container to check Data copied to the specified path.
docker attach b9947aefe406
As you can see file copied at the location
YouTube Link: Copy data in running container
That’s it. docker copy file from copy folder in container