YTread Logo
YTread Logo

Developing on Windows with WSL2 (Subsystem for Linux), VS Code, Docker, and the Terminal

Jun 09, 2021
Hello friends, my name is Scott Hanselman. Now I'm a Windows developer. I have used Windows for many years. I've also used Mac and Linux for years and keep coming back to Windows because, frankly, I like Windows. Maybe not you. No and that's okay, this video is not for you, but if you are someone who doesn't like Windows because it doesn't allow you to develop your Linux applications or your open source applications, I bet you like Windows. interface you like hotkeys you like Explorer and stuff like that you may be like me in fact I enjoy

developing

on Windows I enjoy Windows as a user I use Photoshop in different Windows applications but for a long time I wanted to be able to run my Linux applications and my open source applications, so I tried things like cygwin and it didn't really work for me, but now that Windows 10 supports the Windows Subsystem for Linux, you can run real Linux applications on real Windows and they have a new version open. source

terminal

, which is really cool, it replaces the console and I'll talk about that in a moment.
developing on windows with wsl2 subsystem for linux vs code docker and the terminal
I started using Windows full time, it's my main development machine, but I'm moving seamlessly between containers and Linux and Windows in some ways. That hasn't really been possible until now, so in this video I'm going to show you how to set it up. We will get the

terminal

. We will get that Docker will install WSL using Windows

subsystem

for Linux version. 2 which is now available on Windows 10 Insiders quickly, unless you are reading this in the future and it has been developed, so let's take a look. I know I'm on Insiders Fast, so I'm using Windows 10 Insiders Fast, you can see. here I am on version 1 8 and 9 8 oh you can press the Windows key and press

windows

r and type win view and see the build you have.
developing on windows with wsl2 subsystem for linux vs code docker and the terminal

More Interesting Facts About,

developing on windows with wsl2 subsystem for linux vs code docker and the terminal...

This is the bill that will be out soon. You may have this. a newer version if you are watching this video in the future, so if you have a version of Windows that is in the range of 1800 918 thousand nine hundred and up then you probably have some very interesting things that you may not have converted A couple of things from the ones we want to talk about first are WSL, the Windows

subsystem

for Linux, as well as how it works with Docker and also with vs

code

, specifically the vs

code

remote extensions and then I want to talk about the Windows terminal. the things you need for a new

windows

10, i say experts, fast windows subsystem for

linux

, turn it on,

docker

, get the technical preview, visual studio codes remote extension and windows terminal, if you have those things, You are in a very good place. talk about that, okay, the first thing I want to do is go to the Start menu and type in features.
developing on windows with wsl2 subsystem for linux vs code docker and the terminal
I'm going to go here where it says turn Windows features on and off at the bottom of this here it says Windows subsystem for Linux and the virtual. machine platform now you can do it in this UI if you want or you can go to Windows Store just type search and search for Linux. It's just a regular old Windows Store. I searched for Linux, you can see here that we have run. Linux on Windows, many different Linux, many free, a couple that cost this really cool Linux penguin. I paid for this one. It's actually a custom version of Linux just for the Windows subsystem for Linux with a lot of really cool plugins. -The add-ons are definitely worth it.
developing on windows with wsl2 subsystem for linux vs code docker and the terminal
You can get perk 2 for free when you click on a perk. This actually comes from the people who made it popular. Be sure to click more. You can see here that there is a line in the naval windows optional feature. actually, that's the PowerShell script that you would write in an administrative PowerShell that would trigger this. It's the same as entering that dialog box in the Windows feature and clicking the checkbox. That's the way to programmatically do the next thing I want you to do. search for terminal in Windows Store and search for Windows terminal. It is actually an open source terminal that is currently in preview and this is just getting started.
I think they're on version zero point three or four, but this is really cool. If I start the terminal, I'm going to go ahead and close that this is a replacement for what we consider the cons or the DOSBOX. If I type cmd.exe I get the original DOSBox and I put it in quotes if I type PowerShell. I understand that too. If I type ubuntu, these are all consoles hosted on a thing called conhost, which has been on Windows for a long time. I want to make sure I understand that a console and a shell are different things this terminal is a new console with drop down menus it makes cool animations and stuff if you want I can have a Visual Studio PowerShell you have a useful tool I can have a blue cloud shell I can press settings and I access a JSON file that I can edit and that JSON file allows me to have whatever profile makes me happy, so take a look at this.
I'm going to open my Jason file. I happen to use Visual Studio as my Jason file. editor so here I went and edited my profile to include lubuntu with the source I want with the command line that allows me to use the windows subsystem for

linux

. Now the Windows subsystem for Linux has a small executable that you can use to control it. it's so if you go to daus or powershell or whatever you write wsl - list you can see here. I actually have three different Linux. I can access these three different Linuxes, however I want.
I can execute them by saying WS l. D I can say W Linux, for example, and now I'm on Penguin W Linux, this includes an It is not Dossett, in this case it is PowerShell. I can say that W is cell - Debian and now I'm on Debian very, very quickly. WS l2 is really interesting because it's actually real Linux, it's not any kind of emulated Linux. actually, using a tiny little virtual machine, you can go and see if I bring the task manager here. VM that manages around 500 megabytes of RAM. It's a little mini virtual machine that starts like two three four seconds at most from cold and less than a Second, which is really cool.
You'll notice also the directory on the right, there's mount, see if I actually go to the mount point on my Linux and say forward slash mount, see my other drives as well, so I have full access to my drives and then. I have my blessing for the Linux file system here now, if I want I can go and you know, it's apt-get whatever I have to install node or Ruby or whatever makes me happy but I don't necessarily want to use it . vim if I want more power to you if you like them, but I want to use something like Visual Studio code to do my editing, so what if I went and did something on the right node and did something a little bit different? create directory hey node, okay and let's get into that notice that this is on my lubuntu file system.
I don't have anything there right now and I'm going to write the code now. I have Visual Studio Code installed when I press code even though I'm on Ubuntu look at this it starts Visual Studio Code on Windows okay bottom left corner here it says wsl Ubuntu actually knows I'm Boonta it launched about two and if I go and say open folder something really interesting happens and this blurs the lines between Windows and Linux and why Windows 10 is such an attractive place to do development right now that slash home slash Scott can't be seen: user slash Scott , which is my Windows home folder, on the other hand, it's something else if I go down here and look at my network you see how I have the different things in my house, but if I come here and type Explorer, you know, it's a blessing now dot exe , see what happens with WSL Lubuntu, my filesystems are actually running a plan. 9 Network server that allows me to access these files, so let's go ahead and notice that I'm going to leave it here in the corner, so I'm very blessed to have my application. here that hasn't been created yet within the Visual Studio code and I'm just going to say file new file we're going to call it server I'm just going to save it I'm just going to enter a node code and We're going to hit save server dot j/s okay I'm going to say a little JavaScript file, okay, take a look at this, there's the server, yeah, it's on.
I'm looking at the Ubuntu file system over the network, which is really not a network, because what we're doing here is we're talking about the entire local WSL managing all of this and this is actually very important because you want the best of both worlds, you want the best of the legs and the best of Windows Visual Studio code knows I'm talking to upin. Okay, look at this. I'm going to go ahead and press F5. It says activating extension and says: Hey, what are you doing? What's going on here? We are using node starts running. port 8000, let me know, open Edge now, this is not the Edge that is not fun to run, this is actually what I like to call Edge.
This is the canary version of Edge that now uses Chrome in its core and i. I'm going to type localhost and what are we here on port 8000? There's the hello world of my node application running within the context of the Windows subsystem for Linux. This is interesting because it's actually kind of a small virtual machine, but no. it doesn't feel like a virtual machine it didn't take 15 minutes to load I didn't have to think about I would have to manage it I just typed Ubuntu or typed bash and I get real linux on real windows when it said localhost however is it really local?
Well, it shows up there, they're handling that for us, the localhost port 8000 is actually brokering through sort of access to my Linux Windows subsystem. I don't have to do anything, I'm just set up. anything just works now I'm going to go and just put a breakpoint, refresh again again. I'm on the edge, I'm the new edge, I don't want to call it edge, but Chrome, I'm looking in my file system. Linux inside Windows Explorer Now I'm at a breakpoint inside the Visual Studio code on Windows, but Linux is doing the work and again, if you want to try it, just type H at the top to see what's going on and you'll be able to see the Visual Studio code server. what is happening is that some of the visual studio code is running on linux in wsl.
I'm actually using the mouse scroll control here, so check out this list if you're going to see something and really understand it, take the screenshot of having my friends check it out for pretty slick panels, breakpoint hello world, there is the work in H top on Ubuntu and there is the file on disk pretty fantastic, this is just an example, it could be Python, it could be Ruby, it could be anything else. By the way, it's fun to point out. If I go ahead and max this out, I'll open another tab for Ubuntu and take

docker

images.
I don't currently have docker running, but I will open docker. for Windows here and press start, this is the Docker technical preview. Everything I'm running is free and available for download, so I started Docker and now it looked like Docker. You can now run Docker from Windows RW, so I say Docker images. Look, I have Docker here on Ubuntu. Real Docker doing the real work. Now we can go and make maybe a Hello World image, so I'll say Docker runs HelloWorld. Great, there it is Hello world. I can go back to Windows. The docker images see the same thing.
Docker works there pretty cleverly too, so I could go and run docker and do whatever makes me happy. Those are all the things I wanted to show you today, so we already had the Windows terminal, we have docker. I have remote development running on Windows using Ubuntu but of course I can have other Linux's if I want and I can use the new Windows terminal which is also open source. You can see all of these things and more if you go to my blog and check them out. I've written about the new console every time I talk or about desktop and wsl - all these things you can make happen on your Windows machine.
It's really a very nice time to be a developer on Windows, whether you're a Linux Developer or Node or Python or Ruby or whatever makes you happy, leave a comment if you have an interesting tip or trick on how to be a great developer. and maybe I'll make a video about it, thank you very much.

If you have any copyright issue, please Contact