Setup a Windows Development Environment with WSL2, Docker and VSCode

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello i'm steven and welcome to my video on how to set up a development environment utilizing the windows subsystem for linux 2 and docker and visual studio code with the remote development extensions now you could install docker if you wanted to you'd using the windows desktop installation if you wanted to but i prefer not to biggest reason is i prefer to keep the way i do my installations for docker and stuff on my host machines on the servers so i try to keep it the same way as much as possible now i have seen some issues when using wsl2 really the only issues i've seen personally experienced is when i had a windows 11 machine installed and then i installed wsl 2. i was having issues with the docker environment and the linux vm crashing as soon as i started running the docker containers and started them up uh sometimes it takes a couple minutes sometimes right after i start them up they crash pretty shortly so i went back to windows 10 and i didn't have this problem anymore it just went away so i don't know if it was i don't know if it's because windows 11 or something else but the easiest fix was just to stay away from 11th right now and continue to use 10. the other issue i've had is uh if you've it's very possible if you recently like uh your work environment has say added crowdstrike or a firewall service like that recently it's very possible that they may not be configured correctly to allow wsl 2 to work and what i mean by that is uh when crown cycle was enabled for our machines uh they have get configured to allow wsl-2 to work so they couldn't communicate to the internet correctly uh and stuff like that so you could install packages no no installations or extra stuff like that so uh working with it easy easy enough to fix they just created a specific group for allowing individuals who are doing this to work correctly all right so first things first you need to get we need to get wsl 2 installed so we can utilize it and start getting things done so a couple ways of going about doing that but one is you could just jump right over to the store so let's go ahead and do that and in the store just do a search ubuntu or linux whatever distro you want to use that's available and once you're there you can go ahead and say hey pick your distro install it and let it do its thing but if you prefer you can also do this from powershell and one of the easiest ways to figure out how to do this is to use the uh guides that are online for microsoft themselves so let's go ahead and jump over and do that all right so here we are in firefox and from here you can see i already have a web link pulled up for the wsl install you can do a quick google search or i'll you'll see i leave the links down below in the comments and uh the description of the video so from here really just follow the instructions it's pretty straightforward open up powershell uh wsl dash dash install let's do it it's going to do its thing and you'll be done and then from there all you have to do is wsl install d for distributions so i'm going to jump over and we'll see how this works all right so here we are in powershell and from here we need to do a couple things right so according to the instructions uh one of the first things we need to do is i've already done wsl uh dash dash install so it's already installed on my system and available to me but next thing you'll need to do is actually get a um disk draw installed and one way you can figure out a list of distros is to do wsl dash l dash oh and here we go so all the disk rows are available to install i come in from there it's just wsl install and then the distro name so ubuntu and ubuntu is going to get installed now now once the distro is installed first thing you'll get is a terminal window pops up and from here you're going to provide your username and a password and here we are we're going to start our windows wsl 2 vm and we can go and run command to see where in our home directory and everything so pretty cool that's all you need to do you're ready to go and from here we can go ahead and start getting docker installed so let's go ahead and do that next all right so in order to install docker the way i want to do it is my easiest thing to do is just jump on over and do a quick search for in this case i'm using ubuntu so i'm going to do a search for installing docker for ubuntu and then it'll pop up and really all you need to do is run through the instructions here real quick and you do this you'll have any problems get installed so that's what we're going to do and i'm going to jump back over now and we can go ahead and get this going all right so let's go ahead and start installing our service here now in order to do this i'm going to utilize windows terminal so i'm going to no i actually need to quit terminal all right so now i have terminal install or open and restarted it we can see that just by clicking my drop down we can see my new distro was already added to the terminal so i can go ahead and select that one and we're inside of it now and from here we can go ahead and get started on installing docker and just make sure docker's not installed again sudo service docker start no no don't convey all right so let's get docker installed i've followed the instructions from the website first thing they're going to want you to do is to make sure you don't have a previous version installed so you run that good to go you have to do a update so we'll go ahead and let that run through shouldn't take too long just depending on your own computer and your internet connection but let's go ahead and update the environment or the linux distro and then we go ahead and get the cert information follow that step yes and that'll go ahead and finish up and then from here we go ahead and grab the gpg keys and then move on to the next step here and grab the stable release and from here we should be able to do an update oops got a little squeaky mouse there all right so that's done and now we can go ahead and install docker and it's required components all right so there we go docker is installed so now we can go ahead and start the service so we want to do service uh service docker start docker starting we can check the status see it's running we can find out by just doing dr ps oh wait no permission so we can fix this real quick because i just want to set permissions up on my user account for who am i and i want steven me to have that ability so the easiest way to do it is to to the eye let's see and then groups group come down to the bottom here and see this is in here edit add myself to my user to the group for docker now docker ps i'm not gonna work uh not yet you know what i think in here we actually have to restart it let's find out oh that did not restart uh oh there we go yeah so i had to close the terminal i don't know why but i have to do it all the time close the terminal reopen it and there we go permissions are sticking now all right so docker's up and running now inside the windows subsystem for linux wsl2 uh when you start every time you come back in two if you shut down or restart or anything like that the docker you'll have to restart docker again uh so you have to do the service or sudo service uh docker start whoops you have to make sure you do that every time i think i just typed that wrong yes i did yeah i know get it wrong that should be right there we go so you have to make sure you restart it so you can have docker running all right so before we get started though we have one more thing we need to do and that is to get the docker compose installed correctly so we can utilize compose now in order to do that you can easily do a search and you'll find this site right here which is can i get to it okay so after you do a search for docker installing docker compose should bring you here if not i have the link down below and all you need to do is jump down go to linux and follow these commands there's just these two you need to run right here copy and paste and you'll be good to go so let's go ahead and do that all right so here we are back inside the terminal for our linux box and what we need to do is install docker compose first thing we do is run the one run that command where it gets the file and then we need to make it executable so now we should be able to say doctor compose i think it's dash dashboard there we go docker compose marker oh not like that there we go my bad all right so docker compose is installed ready to go for us and that's really all we need now there is one more thing you want to know uh that's important to know about the windows subsystem which is setting up the config for it so you can restrain resources if you need to because keep in mind this is a vm and it's going to consume resources on your host machine so if you're wanting to have more control over that there is a way to do it so what we'll do is jump over to code real all right so once you're inside of vs code or your own text editor or whatever you'd like to use uh what we can do is say file or yeah file open file and what you should be looking for is underneath users your profile inside of the directory here you should see a file called wsl config if it's not there just make a brand new one and then from there you can go ahead and open it and you can go ahead and add some extra configuration in here like i've done myself so you can see wsl 2 i have a memory constraint of maximum memory it can use for the vm as 12 gigabytes and i'm telling you it can use a total of 12 cpu processors so if you want to do more with this there's plenty more you can do and put it in here and if you wanted to do that what you want to do is go and look up inside your browser and you can go and look up the configuration or configure linux distributions for wsl2 and you can go ahead and read through the page and see a lot of different options on how you can set this up and get different things out so scroll down to the bottom here you can see there's a wsl.conf change mounting options network options user boot and then you get down to one i just showed you the wsl.config and you can see an example here the kernel uh memory limits for the vm and processor limits for the vm so that's where i got this information from and uh it's very helpful especially if uh if you don't have a lot of ram or anything like that maybe you only got eight and something you want to make sure you restrict it you can do that uh and that's how you can restrict the vm itself from the vm level inside your wsl2 all right so that takes care of that next thing we need to do is go ahead and get a our vs code set up so we can use it with wsl2 all right so back in here i'm going to close this because i don't need it anymore and here we are we're inside of wsl2 a couple things we need to do and install first thing i want to do is i have quite a few instant extensions for the stuff i need but the one that you need to you should probably get installed that you'll need in order to interact with it in containers is the remote development you can see it includes uh three packages so you have remote wsl and then remote containers and then it also includes remote ssh and actually for my work for at work for myself i use all these so they're very helpful for everything i'm doing especially for spitting up a quick container to try to figure things out figure out configurations or reproduce things it's really helpful to do that all right so once you get this installed we can go ahead and move on and what we need to do is go over to remote explorer and you can see i have a couple in here so you have you can add new w cell targets but i'm not gonna do it that way uh one way i like to do it is when i'm over inside of or to get a target to get the one i'm working in the disk draw i'm working in to show up i like to just go on over to my terminal again and from here we can see oops dang it i'm missing some keys here okay uh cancel that and i am currently inside here so i want to change to home and i want to do all my work inside of my folder for my user and here we are so back inside of home stephen and one thing you could do is just from here you could easily just type code that will install the vs code server into the environment for your linux environment and then it will open up a window all right so here we are once again inside of vs code and from here you can see we have a new window open and down here the terminal opened with it as well so i can go into pwd and the terminal in here is at our home and it's inside my user scheme so just by typing code inside of the terminal back there in windows terminal we were able to get vs code to open up and bring us right into our environment so we can go down here to remote explorer and we can see down here our current active one is the one of the green check that's when we're inside right now for ubuntu we can go ahead and jump up here to the explorer and we could say open a folder we could open directly to our path if we going to say okay it's gonna ask us to trust it i'm gonna say trust always and voila here we go now we have explorer up on the left hand side it gives us a little bit more functionality for quickly moving around inside the environment uh i did close the terminal now so we could say a new terminal here we are back again in the terminal again it's all good to go and we do see its bash terminal mess around a little bit now from here let's go ahead and get to our environment set up well actually this is our environment so we're basically good to go we could start working with say docker if we wanted to now you don't see the docker on the sidebar here so go to extensions and what you have here is locally installed once for your host and then you have down here in extensions wsl and then the current uh distribution that you're in and you can see we don't have any extensions installed here so there are extensions that we can install over and you can see when you're up here in the local as you scroll down some of them will show stuff like say hey install nwsl ubuntu so i'll go ahead and click on that it's installing now it's down here available popped up on our sidebar i can scroll down a little bit more any other ones that can be installed over there that support it will pop up as well so i can bring over say pretty or prettier can get installed as well so i have that support any other support i want to bring with me is available so from here let's go ahead and jump down to the docker tab and here's our docker so like check to make sure it's still running but it is up and running so we're good to go so now we can go ahead and do all of our work from here and start doing anything we wanted to i mean we can jump over here and explore and open up files edit them and save them uh keep in mind though you you or you need to be like say you did sudo dash i become the root now i won't be able to [Music] do code so your code doesn't work here because it's not installed so it doesn't work when i've had problems with it not supporting like if i studio into another user so stuff like that this over here though is still using my user but we can go ahead and exit out of here come back to us and there we go so we're ready to take our environment and do more with it and i'll cover that in the next video on how to go ahead and get a docker container set up and set up your docker environment so you can start creating work environments where you can stand up a new software really quick if you wanted to a new server interact with them multiple servers at one time but i find this to be a much better environment for myself to work with where vs vs code has a lot of power to it and because it does support all these things in one place where i can use wsl with and create a environment in linux that's very similar or if not identical to what i use at work for my servers and then go ahead and build my data flows or whatever inside a docker test them out locally on my own machine figure out what works what doesn't i can spin them down i can uh destroy them spin them back up real quick and be able to work with them it's a wonderful way to get things done it's really quick for testing and just seeing the capabilities what you want to do but without having to do stuff like a have an extra server stood up that you want to use for a development environment uh you don't have to worry about that don't have to worry about stuff like uh making it easier for yourself for trainer because the interface here is really good for the docker extension when working with wsl so i find it really great to use you have a lot of control over your containers your images the network you can see them very easily the containers are the volumes that you set up as well so i hope this video was helpful and i'll catch you in the next one
Info
Channel: Steven Koon
Views: 566
Rating: undefined out of 5
Keywords: wsl2, wsl, development, environment, docker, linux, howto, ubuntu, visual code studio, developer, setup, vscode, walkthrough, engineer, windows, windows 10, github copilot, data engineer, tutorial, windows subsystem for linux
Id: R88B_ldc6O8
Channel Id: undefined
Length: 21min 10sec (1270 seconds)
Published: Fri Nov 19 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.