Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to mount docker volumes to WSL seamlessly via configuration #715

Open
ThePlenkov opened this issue Sep 18, 2024 · 0 comments
Open
Assignees
Labels
community_new New idea raised by a community contributor

Comments

@ThePlenkov
Copy link

Why?

Whenever we organize local development environment we take care of such requirements as:

  • ability to have OS-indepdent set-up
  • ability to share dev environments
  • ability to backup workspace seamlessly

Devcontainers are very nice tool helping us to reach these goals, however the problem is - how to organize the super-workspace managing all the projects in a best way?

1. Windows workspace

As a developer I used to have Windows 11 due to certain software I need to operate with. At the same time I'd like to develop inside devcontainers to have an OS-independent project setup. I also noticed that it is very slow to use Windows file system for large projects. npm install and other scenarios with intensive I/O workload work much faster in Linux. Luckily we have WSL2 now which solves the problem

2. WSL workspace

The fastest way to start developing in WSL is to clone project there and to open it via devcontainer. However in this case we receive another problem. All the code is stored inside the distro and if it's broken or even worse unregistered - then all your data may be lost.

3. Workspace in a virtual disk mounted to WSL

This is where I am now. I solved the problem of sharing workspace among distros and at same time having an ability to unregister distro without the risk of loosing the actual code. For that puprpose I've created an external virtual drive which I mount on system startup with a command like:

# Mount the VHD
wsl --mount --vhd "$PSScriptRoot\ws.vhdx" --partition 1 --name workspace

This approach allows me to have a Linux workspace stored in the external ext4 virtual drive. However backup problem is not solved. Also it requires some manual actions to set it up.

What is the proposal?

4. Using docker volume instead of the virtual disk

Imagine if instead of creating a virtual disk we create a docker volume. To be able to mount this volume to WSL we need to have a running container.
What if along with WSL integration checkbox we will have an option to choose volumes we would like to mount directly to WSL?
Docker is already mounting internal volumes. Then imagine how simple would be just to follow these steps:

  1. Create a new docker volume ( CLI or GUI ) docker create volume workspace
  2. Configure volume as "WSL integration" volume
  3. Consume volume in WSL via path like /mnt/wsl/docker/volumes/workspace

By doing so - we'll get the ability to set up periodic backups via available export feature.

What do you think of this idea? Does it make any sense? Do you have better proposals may be?

Thanks!

@ThePlenkov ThePlenkov added the community_new New idea raised by a community contributor label Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community_new New idea raised by a community contributor
Projects
None yet
Development

No branches or pull requests

2 participants