Docker Volume Mapping: File is not getting copied from Docker linux container to local windows machine

473 views Asked by At

I am trying to do volume mapping from linux container to my local windows machine.

Here are the steps:

  1. Installed latest version of Docker desktop for windows (2.4.0.0) and it's currently using WSL2 based engine.
  2. Started a container using my own image on top of alpine image. Working directory is set to '/app' in linux container.
  3. An output file (Report.html) is created under a folder (Reports) in my linux container once it is run. Able to view the file in container.
  4. I would like to save the output file to a folder named 'Output' under my user directory in local windows machine.

Ran the following command in Power Shell in Admin mode:

docker run -it -v ~/Output:/app/Reports <imagename>

Issue: Output file (Report.html) does not get copied to Output folder in local machine.

Note: I don't see the option to select drive for file sharing in Docker settings. enter image description here

Please guide me on how I can resolve this ?

1

There are 1 answers

0
newuser On BEST ANSWER

Using absolute path in place of ~ worked, i.e. docker run -v C:/Users/12345/Output:/app/Reports