How do I get my source code into WSL?

Hey there!

I’m very, very new to Docker and am using the Docker setups provided by my company. Unfortunately developing on Windows is quite slow with Docker for me. I’ve read a lot about the problem being the copying of my source code to WSL and then to the Container is what takes so much time, but I don’t understand how to go from here.
Should I put my source code into WSL? How would I do that?
Or does it have to do something with with best practice from the Docker Desktop WSL 2 backend documentation:

  • Performance is much higher when files are bind-mounted from the Linux filesystem, rather than remoted from the Windows host. Therefore avoid docker run -v /mnt/c/users:/users (where /mnt/c is mounted from Windows).
  • Instead, from a Linux shell use a command like docker run -v ~/my-project:/sources <my-image> where ~ is expanded by the Linux shell to $HOME .

I do have a docker-compose file, containing several services, one of which has the following volumes defined:

    - ${APP_PATH_HOST:-./}:/var/www/shophelper
    - ./docker/nginx:/etc/nginx/conf.d/
    - ./storage/logs/nginx:/var/log/nginx
    - ./localhost.crt:/etc/ssl/certs/localhost.crt
    - ./localhost.key:/etc/ssl/private/localhost.key

As far as I understand the “${APP_PATH_HOST:-./}” part before “/var/www/shophelper” is the full length path to the project dir in my Windows host file system and this is what should be changed to “~/my-project” from the documentation. However if I just write it like this: “~/shop-helper:/var/www/shophelper” with “shop-helper” being the name of the project dir, it doesn’t work.

Does anybody know what I’m doing wrong? Unfortunately I don’t even know what to google anymore, I feel kind of lost :frowning:

Thank you for reading. Any help would be greatly appreciated :slight_smile:

It realy depends on your tools and workflow.

I personaly prefer to register a ci/cd pipeline that builds a new image with the current sources whenever sources are pushed to one of my git repos.

And If it’s about running a container, then I checkout sources in WSL2 and go from there. If you use vscode, the “Remote - WSL” extension is very helpfull, as it allows your Windows VSCode to have its working scope inside a WSL2 distribution.

Other options:

  • use the existing source from your Windows filesystem using WSL2 interop (that what’s Docker Desktop does → slow access!)
  • copy your existing sources into the filesystem of your WSL2 distro. Open \\wsl$ in the explorer to see the exact path for the disitribution and path you want to copy your sources into.

I would not recommend any of the other options, as they are slow and/or cumbersom.

1 Like