Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy files from Windows host to Docker container

Tags:

docker

windows

Looking for a quick solution to copy local files to a Docker container on Windows. I wasn't able to find this in other Stack Overflow solutions.

You might call this mounting a local drive on Windows within a docker container.

like image 894
James Gentes Avatar asked Jul 25 '16 15:07

James Gentes


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.


Video Answer


1 Answers

Open the Docker settings from the icon on the taskbar:

Docker popup

Go to 'Shared Drives' and enable your local drive to be made accessible to your containers:

Docker shared drive settings

Now you can add folders from your shared drive as a volume in a container. Using the nginx example from the Docker getting started guide:

docker run -it -v c:/Users:/data nginx /bin/bash

That will give you shell access, where you can find your local files (c:/Users) in the /data directory of your nginx container.

like image 103
James Gentes Avatar answered Nov 15 '22 05:11

James Gentes