1

I have tried this example out on a windows 10 box which has WSL2 installed and integrated with the latest Docker version. After following the steps in the example and downloading the code in the linux subsystem, I am able to build the image and run the container. The website is also available on the browser when I browse to it on a browser running on Windows 10. However, when I create a file or folder in the container the same doesn't reflect in the host filesystem which in this case is the linux subsystem. Similarly, a file created in the host linux subsystem is not seen in the container's cli when I use the ls command.

I ran this commands to confirm that the folder has been mounted where 44711fc95366 is my container id

docker inspect -f "{{ .Mounts }}" 44711fc95366

This gives an output like so:

[{bind /home/userlab1/my-proj/getting-started/app /usr/src/app true rprivate}]

If the mount point expressed above is correct, I should be able to create a file or folder in host subsystem on the path /home/userlab1/my-proj/getting-started/app and be able to see it at the /usr/src/app path in the container, correct?

The docker image has been created and run from the linux subsystem command line like so:

docker run -it -v ~/my-proj/getting-started/app:/usr/src/app -p 3001:3000 --name cntr-linux-todo
img-todo:in-linux

While the application runs, the files updated in the container don't reflect on the website that is running from the container, nor does a new file/folder created in the container be seen in the host subsystem and vice versa. What am I missing?

user20358
  • 14,182
  • 36
  • 114
  • 186

1 Answers1

1

As you are using Windows's version of docker, it cannot see files/folders from WSL.

You can move ~/my-proj into C:\Users\user20358, and mount from there :

-v 'C:\Users\user20358\my-proj\getting-started\app:/usr/src/app'
Philippe
  • 20,025
  • 2
  • 23
  • 32
  • thanks for the reply. As per documentation, I need to store the files in the linux subsystem and not in the windows filesystem, so I cloned the code in the ubuntu shell. I am working exclusively in the linux filesystem. How does the host file system you mentioned above differ from any other path on the windows box? – user20358 Jan 02 '21 at 19:19
  • Windows paths can be accessed both by Windows and WSL, but WSL paths can only be accessed by WSL. Have tried my method ? – Philippe Jan 02 '21 at 19:23
  • yes. It didn't work. I am running docker on windows. I am building the image and running the `docker run` command in the wsl ubuntu though. When I run docker in hypervisor mode using Linux containers it works, but when I switch to using the wsl2 based engine it doesn't. As per documentation here https://docs.docker.com/docker-for-windows/wsl/#develop-with-docker-and-wsl-2 I have even installed the plugin for VSCode and it can't detect the files I have created or updated using vscode. – user20358 Jan 02 '21 at 19:30