Reputation: 31
I was trying to copy a folder from my local host to a docker container in the interactive mode using the following docker command:
docker run -it -v /folder/folder/workspace/folder/folder/*:/tool-1.0/Projects/DemoProject/ --name container imagename
The contents of the folder in the container are getting removed when I run the above command.
Is there any other way to copy the folder into a container?
Upvotes: 0
Views: 4338
Reputation: 51738
When you use the -v
option you are mouting a volume from the host onto the container folder location. This will effectively "override" files that exist in the container.
You still can use this option, but mount the host folder onto a non-ecisting subdirectory in the container:
docker run -it -v /folder/folder/workspace/folder/folder:/tool-1.0/Projects/DemoProject/folder --name container imagename
Alternatively, don't use the volume option and just start the container and the copy the files from the host into the started container using:
docker run -it --name container imagename
docker cp /folder/folder/workspace/folder/folder/* container:/tool-1.0/Projects/DemoProject
Upvotes: 1
Reputation: 6519
use docker cp command
make folder as tar and move to running container using below command
ref : https://docs.docker.com/engine/reference/commandline/cp/
Upvotes: 1