Copy Data From Docker Host In a Running Container

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.

touch vhost.conf

Check Out: Create Apache Image Using Dockerfile

Copy files

docker cp /root/vhost.conf b9947aefe406:/etc/httpd/

copy folder in container

Access the container to check Data copied to the specified path.
docker attach b9947aefe406

Check Out: Download Specific Version of Any image In Docker

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

Share on:

I'm the founder of Curious Viral. I hope this blog will provide you complete information about Linux Technology & I would like to share my technical knowledge with you which I have learned during this period.

Other Posts You May Like...

Leave a comment