How to copy files from Windows host to Docker cont

2019-04-30 02:07发布

问题:

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.

回答1:

Open the Docker settings from the icon on the taskbar:

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

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.



回答2:

If windows OS is not win 10 pro, then the docker is installed usnig Docker Toolbox. In this case one may not find settings dialogue option in the taskbar. See here https://stackoverflow.com/questions/42326563/mounting-windows-drives-to-access-from-docker for a way to mount windows folders to access from containers.