There's nothing wrong with this command, but the "scope" is WSL shell, and while using the docker nix command, the path of the volume is the windows one.There should be a better way, no?

WSLENV to save the day

Luckily, the WSL team did already implement a very nice feature, WSLENV, and a linux command, wslpath that will help translating the Windows path.Now it would be up to you to either create, in Windows, an environment variable and use it.Here is the same example, using LCOW (because why not), for mounting volumes in a "linux way":

Mixing all and having fun

Playing with the paths, is nice, but it's a tweet from the legendary Scott Hanselman that triggered an idea even crazier: try the same with windows commands in WSL shell.First of all, we need to understand what I call the "scope" between a command and the shell used to run it.In Scott's example, he's piping a value from a windows command (dir) to a bash one (grep).The pipe, is a Shell function, not related to the command itself.So with that in mind, here is the example from before but with docker.exe from WSL:

If you're using Powershell as the default, you will have to do like Scott shown in his example: put "wsl.exe" before your linux command. You need to define the scope.

Just concerning the Docker examples, the volume sharing has to be in Windows path format for both commands (linux and windows).See Craig's notes on his blog.

Conclusion

The more WSL is evolving, the more I see no boundaries in Interop and I'm really looking forward to the first linux and/or windows applications that would use this capability natively.

Last but not least, Interop is really a state of mind. If you can look beyond the "walls" separating both worlds and instead embrace the fact that water and oil can mix, believe me when I tell you that the fun is infinite.

Ok, and a weird mind can help having crazy ideas...

>>> Nunix Out <<<

Get link

Facebook

Twitter

Pinterest

Email

Other Apps

Get link

Facebook

Twitter

Pinterest

Email

Other Apps

Comments

Post a Comment

Popular posts from this blog

IntroductionThis blog post will explain how a single home mount can be shared accross all the WSL instances. It was quite fun to find the idea and then make it happen. It will use all the tools currently available from WSL, so please don't expect a "Linux only" as Interopability will be heavily used. And before I start, here is my point of view about WSL: It's not only Linux!It's different, just like GNU is different from Unix (yes I said it).We have finally the strength of both worlds combined. And while I do understand the "dev" aspect is meant to be reproducible in a Linux prod environment, the "ops" side is meant to take advantages of everything that can make the full environment feeling Home.
Setup requirementsIn order to really enjoy this solution, I do recommend having 2 or more WSL distros installed or, if you fell like a real WSLCorsair, try @bketelsencrazy setup (I love it)! While the distros are downloading, let's prepare the Windo…

!!! Warning !!!Once again, let me repeat, I'm by no means a developer nor a sysadmin (at least no more since 5 years).This means that, while the solution below worked for me and I could reproduce it, it's not 100% safe neither!Also, my solution still feels incomplete (read further), so if someone know the tweak to make it even more compete, please share it and reach out in Twitter, I'll be waiting.IntroductionBy now, everyone following @jessfraz read her take about the very neat "little hack" from @cloudflare: Using Go as a scripting language in Linux

As a good WSL Corsair, I tried it and it just worked!But then, based on my latest playground of having a seamless coding experience between WSL and Windows (thanks @bketelsen for the love and notification spam), I really thought it would be unfair to "my Windows side" to not be able enjoying the fun of GO scripting (yes, split personality is bad).