Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy files from local machine to docker container on windows

I have to import data files from a user local file C:/users/saad/bdd to a docker container (cassandra), I didn't find how to proceed using docker commands. I'm working on windows 7.

like image 946
Manou Avatar asked Oct 28 '16 21:10

Manou


People also ask

Can you copy a file from local to run container?

Description. The docker cp utility copies the contents of SRC_PATH to the DEST_PATH . You can copy from the container's file system to the local machine or the reverse, from the local filesystem to the container.


2 Answers

Use docker cp.

docker cp c:\path\to\local\file container_name:/path/to/target/dir/ 

If you don't know what's the name of the container, you can find it using:

docker ps --format "{{.Names}}" 
like image 50
Alvaro Carvajal Avatar answered Sep 28 '22 11:09

Alvaro Carvajal


When using docker toolbox, there seems to be another issue related to absolute paths.

I am communicating with the containers using the "Docker Quickstart Teminal" which essentially is a MINGW64 environment.

If I try to copy a file with an absolute path to a container, I receive the error message.

$ docker cp /d/Temp/my-super-file.txt container-name:/tmp/ copying between containers is not supported 

If I use a relative path, it simply works.

$ cd /d/ $ docker cp Temp/my-super-file.txt container-name:/tmp/ 

P.S.: I am posting this as an answer because of missing reputation for a comment.

like image 27
DwightKendall Avatar answered Sep 28 '22 10:09

DwightKendall