I would like to work on a web project relying on Docker and NPM (This is actually a LAMP server). I am running on WSL with the Docker daemon running on Windows.
Here are my constraints:
/mnt/c/...
npm
which use soft links, I must locate my project on the WSL filesystem e.g./srv/...
Obviously I cannot meet these two requirements.
For instance if I do npm install from WSL on a folder located on the Windows filesystem I get plenty of errors such as:
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
Or, simply the modules don't work webpack not found
If I move my project on the WSL side, Docker is not able to mount my project on my target container...
What alternative can I use?
When using WSL, Docker for Windows expects you to supply your volume paths in a format that matches this: /c/Users/username/dev/myapp
.
But WSL uses the /mnt/c/Users/username/dev/myapp
format.
You have to configure WSL to mount at /
instead of /mnt
.
Create and modify the new WSL configuration file:
sudo nano /etc/wsl.conf
# Now make it look like this and save the file when you're done:
[automount]
root = /
options = "metadata"
We need to set root = / because this will make your drives mounted at /c or /e instead of /mnt/c or /mnt/e.
The options = "metadata" line is not necessary but it will fix folder and file permissions on WSL mounts so everything isn't 777 all the time within the WSL mounts. I highly recommend you do this!
Once you make those changes, sign out and sign back in to Windows to ensure the changes take effect
source: https://nickjanetakis.com/blog/setting-up-docker-for-windows-and-wsl-to-work-flawlessly
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.