← Back
Mischa Vandenburg May 3, 2024 14m

Start CODING IN MINUTES with DevContainers

Read full transcript 10 segments
  1. hi there my name is Misha and I'm an hi there my name is Misha and I'm an Azure MVP and today I'm going to show Azure MVP and today I'm going to show Azure MVP and today I'm going to show you a little bit about Dev containers you a little bit about Dev containers you a little bit about Dev containers this is something that I've been this is something that I've been this is something that I've been intrigued with for a while and I hadn't intrigued with for a while and I hadn't intrigued with for a while and I hadn't really tried it out myself but I really tried it out myself but I really tried it out myself but I actually started dipping my toes into C actually started dipping my toes into C actually started dipping my toes into C and net development recently and I I I'm and net development recently and I I I'm and net development recently and I I I'm running Mac OS and yeah if you've done running Mac OS and yeah if you've done running Mac OS and yeah if you've done this before on a Linux or Mac OS system this before on a Linux or Mac OS system this before on a Linux or Mac OS system it is a real hassle to get the net run it is a real hassle to get the net run it is a real hassle to get the net run times to install correctly and to be times to install correctly and to be times to install correctly and to be available in all programs and this had available in all programs and this had available in all programs and this had me thinking about yeah there are me thinking about yeah there are me thinking about yeah there are solutions to this and one of them is Dev solutions to this and one of them is Dev solutions to this and one of them is Dev containers so a Dev container is containers so a Dev container is containers so a Dev container is something that is being run in vs code something that is being run in vs code something that is being run in vs code and if you know me if you have been and if you know me if you have been and if you know me if you have been following me for a while you know that following me for a while you know that following me for a while you know that I'm a heavy Vim user and I'm I live on I'm a heavy Vim user and I'm I live on I'm a heavy Vim user and I'm I live on the command line but when using the command line but when using the command line but when using Microsoft Technology sometimes I've been Microsoft Technology sometimes I've been Microsoft Technology sometimes I've been utilizing vs code there's no shame in utilizing vs code there's no shame in utilizing vs code there's no shame in that and one of the greatest features that and one of the greatest features that and one of the greatest features about that are Dev containers so you about that are Dev containers so you about that are Dev containers so you know I'm just going to show not tell know I'm just going to show not tell know I'm just going to show not tell right so I have this repo here that right so I have this repo here that right so I have this repo here that contains a very simple net C project now contains a very simple net C project now contains a very simple net C project now I am a developer working at a at a I am a developer working at a at a I am a developer working at a at a Enterprise and I'm being onboarded to a Enterprise and I'm being onboarded to a Enterprise and I'm being onboarded to a new project well usually that entails new project well usually that entails new project well usually that entails having to install certain Frameworks having to install certain Frameworks having to install certain Frameworks that every project is the is is that every project is the is is that every project is the is is different different different every every project has their own set of

  2. every every project has their own set of every every project has their own set of tooling has their own little specific tooling has their own little specific tooling has their own little specific things that you need to have on your things that you need to have on your things that you need to have on your local system and if you've done this local system and if you've done this local system and if you've done this before you will know that it's usually a before you will know that it's usually a before you will know that it's usually a bit of a hassle to get all of that up bit of a hassle to get all of that up bit of a hassle to get all of that up and running now with Dev containers you and running now with Dev containers you and running now with Dev containers you actually can Define this in code and actually can Define this in code and actually can Define this in code and package all of this so that your entire package all of this so that your entire package all of this so that your entire environment is actually being run in a environment is actually being run in a environment is actually being run in a container so I have this repo here and container so I have this repo here and container so I have this repo here and I'm going to clone it it's on my own G I'm going to clone it it's on my own G I'm going to clone it it's on my own G um system and just just to show you if I um system and just just to show you if I um system and just just to show you if I do net list run do net list run do net list run times I have only ASP core 7.0 and times I have only ASP core 7.0 and times I have only ASP core 7.0 and 8.0 and net core 7.0 and 8.0 that's all 8.0 and net core 7.0 and 8.0 that's all 8.0 and net core 7.0 and 8.0 that's all I have and if I do net list SD I have and if I do net list SD I have and if I do net list SD case SDC case you see I only have 7.0 case SDC case you see I only have 7.0 case SDC case you see I only have 7.0 and 8.0 I don't have any any other and 8.0 I don't have any any other and 8.0 I don't have any any other versions installed on my system now this versions installed on my system now this versions installed on my system now this project is net 6 it's an older version I project is net 6 it's an older version I project is net 6 it's an older version I don't have that here but say I have to don't have that here but say I have to don't have that here but say I have to do some work on an older Legacy project do some work on an older Legacy project do some work on an older Legacy project that I uh that needs to be updated well that I uh that needs to be updated well that I uh that needs to be updated well I have this script on my uh system where I have this script on my uh system where I have this script on my uh system where I can just write clone and then the repo I can just write clone and then the repo I can just write clone and then the repo name the user and the repo name so it's name the user and the repo name so it's name the user and the repo name so it's now going to clone and it's going to CD now going to clone and it's going to CD now going to clone and it's going to CD into the directory so now I have my uh into the directory so now I have my uh into the directory so now I have my uh my repo clone here and here you see I

  3. my repo clone here and here you see I my repo clone here and here you see I have my program.cs and I have myev have my program.cs and I have myev have my program.cs and I have myev container directory here too now if I container directory here too now if I container directory here too now if I open this directory in vs code by typing open this directory in vs code by typing open this directory in vs code by typing code code code dot then vs code is going to open up and dot then vs code is going to open up and dot then vs code is going to open up and I'm just going to move that to a I'm just going to move that to a I'm just going to move that to a different desktop so here and here down different desktop so here and here down different desktop so here and here down in the bottom right my head is probably in the bottom right my head is probably in the bottom right my head is probably covering it uh let me see can I can I covering it uh let me see can I can I covering it uh let me see can I can I show that show that show that here yeah here so here in the bottom here yeah here so here in the bottom here yeah here so here in the bottom right there is a little prompt here right there is a little prompt here right there is a little prompt here where it says this folder contains a Dev where it says this folder contains a Dev where it says this folder contains a Dev container configuration file do you want container configuration file do you want container configuration file do you want to reopen this as a container well let's to reopen this as a container well let's to reopen this as a container well let's do reopen in do reopen in do reopen in container and what's happening now is I container and what's happening now is I container and what's happening now is I have Docker running on my local have Docker running on my local have Docker running on my local system uh more specifically I'm I'm system uh more specifically I'm I'm system uh more specifically I'm I'm running Rancher desktop to um as my running Rancher desktop to um as my running Rancher desktop to um as my docker docker docker and now this now this has actually and now this now this has actually and now this now this has actually started up a container running on my started up a container running on my started up a container running on my local um MacBook on my local machine local um MacBook on my local machine local um MacBook on my local machine which contains all of the dependencies I which contains all of the dependencies I which contains all of the dependencies I need to work with this project so this need to work with this project so this need to work with this project so this terminal here that I am running is terminal here that I am running is terminal here that I am running is actually actually actually running an entire OS of itself so if I running an entire OS of itself so if I running an entire OS of itself so if I do cat Etc OS do cat Etc OS do cat Etc OS release I am now in Debian Bookworm and

  4. release I am now in Debian Bookworm and release I am now in Debian Bookworm and this is not Mac OS but which I'm running this is not Mac OS but which I'm running this is not Mac OS but which I'm running on my local machine and now the cool on my local machine and now the cool on my local machine and now the cool thing is if I now do thing is if I now do thing is if I now do net net net list uh run list uh run list uh run times here you see I have net times here you see I have net times here you see I have net 6 available to me and I hadn't I didn't 6 available to me and I hadn't I didn't 6 available to me and I hadn't I didn't install anything on my own machine like install anything on my own machine like install anything on my own machine like if I go back to my terminal if I now do if I go back to my terminal if I now do if I go back to my terminal if I now do net uh list sdks 7.0 still and run times net uh list sdks 7.0 still and run times net uh list sdks 7.0 still and run times if I list that still seven and eight net if I list that still seven and eight net if I list that still seven and eight net 6 is not installed on my local system 6 is not installed on my local system 6 is not installed on my local system yet I have just cloned a repo and here I yet I have just cloned a repo and here I yet I have just cloned a repo and here I have net 6 available so if I do net have net 6 available so if I do net have net 6 available so if I do net run run run and if it's now starting up my and if it's now starting up my and if it's now starting up my application and it's now going to ask me application and it's now going to ask me application and it's now going to ask me do I want to open this in a browser and do I want to open this in a browser and do I want to open this in a browser and here we go I just have this really here we go I just have this really here we go I just have this really simple demo application which just says simple demo application which just says simple demo application which just says the net version of this project is 6.0 the net version of this project is 6.0 the net version of this project is 6.0 and it's nice weather today blah blah and it's nice weather today blah blah and it's nice weather today blah blah blah so it's it's really powerful it blah so it's it's really powerful it blah so it's it's really powerful it shows you shows you shows you that you can actually pull in a project that you can actually pull in a project that you can actually pull in a project and have it up and running without and have it up and running without and have it up and running without having to install anything on your local having to install anything on your local having to install anything on your local machine in terms of uh stuff that you machine in terms of uh stuff that you machine in terms of uh stuff that you need so how how how is this done how how need so how how how is this done how how need so how how how is this done how how do you do this well you um in the repo

  5. do you do this well you um in the repo do you do this well you um in the repo here and I'm just going to open Vim but here and I'm just going to open Vim but here and I'm just going to open Vim but I I I could also just do it here in vs I I I could also just do it here in vs I I I could also just do it here in vs code here is the the dev container. Json code here is the the dev container. Json code here is the the dev container. Json and if I open it here Dev and if I open it here Dev and if I open it here Dev container container container Json all it does all it sees here is it Json all it does all it sees here is it Json all it does all it sees here is it it takes an image just like you would do it takes an image just like you would do it takes an image just like you would do like Docker Run images Engine like Docker Run images Engine like Docker Run images Engine X it takes a b image with net 6 so that X it takes a b image with net 6 so that X it takes a b image with net 6 so that contains the runtime and here I can uh contains the runtime and here I can uh contains the runtime and here I can uh add customizations and extensions to my add customizations and extensions to my add customizations and extensions to my container so this container actually container so this container actually container so this container actually comes with the comes with the comes with the c um dev kit installed in the dev c um dev kit installed in the dev c um dev kit installed in the dev container and here also um a few other container and here also um a few other container and here also um a few other extensions have been uh installed let me extensions have been uh installed let me extensions have been uh installed let me just close this these are my local ones just close this these are my local ones just close this these are my local ones here in my Dev container I have C devkit here in my Dev container I have C devkit here in my Dev container I have C devkit c.net install tool and all of these c.net install tool and all of these c.net install tool and all of these things are already installed in my net things are already installed in my net things are already installed in my net container based on the extension here container based on the extension here container based on the extension here and on my local uh extensions too so you and on my local uh extensions too so you and on my local uh extensions too so you can Define in code what you want to can Define in code what you want to can Define in code what you want to include in the dev container that your include in the dev container that your include in the dev container that your project is going to need so this is project is going to need so this is project is going to need so this is super powerful because you can actually super powerful because you can actually super powerful because you can actually standardize your particular Dev standardize your particular Dev standardize your particular Dev environment for your entire project now environment for your entire project now environment for your entire project now and in to to create this it's really and in to to create this it's really and in to to create this it's really simple you have the dev containers simple you have the dev containers simple you have the dev containers extension here in vs code uh let's see

  6. extension here in vs code uh let's see extension here in vs code uh let's see Dev Dev Dev Dev Dev Dev container oh Dev here Dev containers is container oh Dev here Dev containers is container oh Dev here Dev containers is just an extension that you just an extension that you just an extension that you install and then when you have in install and then when you have in install and then when you have in installed this and you have a some sort installed this and you have a some sort installed this and you have a some sort of Docker engine running on your machine of Docker engine running on your machine of Docker engine running on your machine this can be Docker desktop podman this can be Docker desktop podman this can be Docker desktop podman uh rencher desktop whatever and then uh rencher desktop whatever and then uh rencher desktop whatever and then when you have installed this you when you have installed this you when you have installed this you actually get these Dev container you can actually get these Dev container you can actually get these Dev container you can um you get like all of these commands um you get like all of these commands um you get like all of these commands with um that you can interact with the with um that you can interact with the with um that you can interact with the dev containers and also you can do new dev containers and also you can do new dev containers and also you can do new Dev container here for example so here Dev container here for example so here Dev container here for example so here you have all of these templates so if I you have all of these templates so if I you have all of these templates so if I want to create a new net Dev container want to create a new net Dev container want to create a new net Dev container well I I can pick this but there is also well I I can pick this but there is also well I I can pick this but there is also asure functions. net what else do we asure functions. net what else do we asure functions. net what else do we have here barebones Ruby python go we have here barebones Ruby python go we have here barebones Ruby python go we can go and post let's check out what can go and post let's check out what can go and post let's check out what does um create Dev container go post does um create Dev container go post does um create Dev container go post Crest what does that Crest what does that Crest what does that do all right so we are now opening a Dev do all right so we are now opening a Dev do all right so we are now opening a Dev container and it's going to install a container and it's going to install a container and it's going to install a bunch of stuff and I'm actually bunch of stuff and I'm actually bunch of stuff and I'm actually wondering what how this is going to wondering what how this is going to wondering what how this is going to affect the repo that's going to be fun affect the repo that's going to be fun affect the repo that's going to be fun to see but it is now just building a to see but it is now just building a to see but it is now just building a completely new Dev container which I can completely new Dev container which I can completely new Dev container which I can use as a starting point for my project use as a starting point for my project use as a starting point for my project so now I'm I'm starting a go postgress so now I'm I'm starting a go postgress so now I'm I'm starting a go postgress project and I can have vs code build

  7. project and I can have vs code build project and I can have vs code build this up for me as an example and then if this up for me as an example and then if this up for me as an example and then if I want to have extra extensions in my I want to have extra extensions in my I want to have extra extensions in my Docker container that I think oh maybe Docker container that I think oh maybe Docker container that I think oh maybe my developers need this or in order to my developers need this or in order to my developers need this or in order to really use this project we need that you really use this project we need that you really use this project we need that you can just Define that include that in the can just Define that include that in the can just Define that include that in the dev container dev container dev container Json and you include that with the repo Json and you include that with the repo Json and you include that with the repo and then the next person can just pull and then the next person can just pull and then the next person can just pull in that repo start up the project open in that repo start up the project open in that repo start up the project open it in a Dev container and it has it in a Dev container and it has it in a Dev container and it has everything they need to get up and everything they need to get up and everything they need to get up and running and this is just extremely running and this is just extremely running and this is just extremely extremely powerful if you have ever if extremely powerful if you have ever if extremely powerful if you have ever if youve ever been uh struggling with youve ever been uh struggling with youve ever been uh struggling with getting a local de environment up and it getting a local de environment up and it getting a local de environment up and it works on my machine but it doesn't work works on my machine but it doesn't work works on my machine but it doesn't work on your machine this is the solution to on your machine this is the solution to on your machine this is the solution to that problem this is the solution to it that problem this is the solution to it that problem this is the solution to it so as you see it is all doing it all so as you see it is all doing it all so as you see it is all doing it all automatically and um it is all it's automatically and um it is all it's automatically and um it is all it's building the images it is pulling them building the images it is pulling them building the images it is pulling them in and I am let's see go postgress it in and I am let's see go postgress it in and I am let's see go postgress it still has to wait until it's done still has to wait until it's done still has to wait until it's done apparently later and here we go here is our def later and here we go here is our def container all up and running so there is container all up and running so there is container all up and running so there is what it has created is a Docker file what it has created is a Docker file what it has created is a Docker file where it takes the go base image um this where it takes the go base image um this where it takes the go base image um this is a an image that Microsoft created for is a an image that Microsoft created for is a an image that Microsoft created for go and here is a Docker compost. yaml it go and here is a Docker compost. yaml it go and here is a Docker compost. yaml it created where we have a database being

  8. created where we have a database being created where we have a database being started and now I have the I have a started and now I have the I have a started and now I have the I have a database running it's being Port database running it's being Port database running it's being Port forwarded here and I now have a starting forwarded here and I now have a starting forwarded here and I now have a starting point for my project and if I do point for my project and if I do point for my project and if I do everything from the dev container Json everything from the dev container Json everything from the dev container Json and if I'm I'm careful to include the and if I'm I'm careful to include the and if I'm I'm careful to include the extensions here so let's say I want to extensions here so let's say I want to extensions here so let's say I want to include the Vim extension into this Dev include the Vim extension into this Dev include the Vim extension into this Dev container for example then I can just do container for example then I can just do container for example then I can just do this Vim extension and I can do add to this Vim extension and I can do add to this Vim extension and I can do add to Def container. Json here boom and now Def container. Json here boom and now Def container. Json here boom and now customizations the extension Vim is customizations the extension Vim is customizations the extension Vim is being added and yeah as you know me I I being added and yeah as you know me I I being added and yeah as you know me I I am very dependent on the Vim key am very dependent on the Vim key am very dependent on the Vim key bindings so my personal bindings so my personal bindings so my personal Dev containers will always include the Dev containers will always include the Dev containers will always include the Vim key bindings in the extension and Vim key bindings in the extension and Vim key bindings in the extension and here we go it is already in so the next here we go it is already in so the next here we go it is already in so the next person the next time I can just delete person the next time I can just delete person the next time I can just delete all of this from my PC and then the next all of this from my PC and then the next all of this from my PC and then the next time I want to be working on this go time I want to be working on this go time I want to be working on this go post crust project I pull in the dev post crust project I pull in the dev post crust project I pull in the dev container I can open it in vs code and I container I can open it in vs code and I container I can open it in vs code and I have everything up and running including have everything up and running including have everything up and running including my beloved Vim extension so this is my beloved Vim extension so this is my beloved Vim extension so this is super powerful and I'm now sort of super powerful and I'm now sort of super powerful and I'm now sort of starting to explore explore this how I starting to explore explore this how I starting to explore explore this how I can use this uh in my own workflow can use this uh in my own workflow can use this uh in my own workflow because yes as I said I I'm I I prefer because yes as I said I I'm I I prefer because yes as I said I I'm I I prefer to work in the the terminal so I like to to work in the the terminal so I like to to work in the the terminal so I like to have everything available to me in Vim have everything available to me in Vim have everything available to me in Vim so I can I can always just have the dev so I can I can always just have the dev so I can I can always just have the dev container open and I can edit the code

  9. container open and I can edit the code container open and I can edit the code here manually um like I can add edit the here manually um like I can add edit the here manually um like I can add edit the code here so as you know I'm a Vim guy code here so as you know I'm a Vim guy code here so as you know I'm a Vim guy and I really like to um edit my code and I really like to um edit my code and I really like to um edit my code from the terminal and not necessarily in from the terminal and not necessarily in from the terminal and not necessarily in vs code so I can just go into the the vs code so I can just go into the the vs code so I can just go into the the dev container directory uh and I can I dev container directory uh and I can I dev container directory uh and I can I can edit the code here I can there's no can edit the code here I can there's no can edit the code here I can there's no no nothing against so yes all of this is no nothing against so yes all of this is no nothing against so yes all of this is now being run in vs code and I can edit now being run in vs code and I can edit now being run in vs code and I can edit my Dev container that yo and I can edit my Dev container that yo and I can edit my Dev container that yo and I can edit my code from vs code but as you know I'm my code from vs code but as you know I'm my code from vs code but as you know I'm a I'm a Vim guy and I'm sort of a I'm a Vim guy and I'm sort of a I'm a Vim guy and I'm sort of exploring all of this now and and trying exploring all of this now and and trying exploring all of this now and and trying to incorporate this in my own workflow to incorporate this in my own workflow to incorporate this in my own workflow and so there's there's nothing in the and so there's there's nothing in the and so there's there's nothing in the way of me editing my code here and it way of me editing my code here and it way of me editing my code here and it will this is just the the files that are will this is just the the files that are will this is just the the files that are on my local system these are being on my local system these are being on my local system these are being mounted in the dev container so all of mounted in the dev container so all of mounted in the dev container so all of the things that I'm changing here are the things that I'm changing here are the things that I'm changing here are reflected in the dev container that's reflected in the dev container that's reflected in the dev container that's not a problem uh but I'm now going to be not a problem uh but I'm now going to be not a problem uh but I'm now going to be exploring how I can either attach to Dev exploring how I can either attach to Dev exploring how I can either attach to Dev container from neovim or maybe there's container from neovim or maybe there's container from neovim or maybe there's already an extension for neovim uh that already an extension for neovim uh that already an extension for neovim uh that enables you to work with Dev containers enables you to work with Dev containers enables you to work with Dev containers this is something new I'm going to be this is something new I'm going to be this is something new I'm going to be exploring so stay tuned if you're exploring so stay tuned if you're exploring so stay tuned if you're interested in that but even though I'm a interested in that but even though I'm a interested in that but even though I'm a like a a Vim um fanatic like vs code like a a Vim um fanatic like vs code like a a Vim um fanatic like vs code this this like functionality of being this this like functionality of being this this like functionality of being able to pull in a project and get up and

  10. able to pull in a project and get up and able to pull in a project and get up and running so quickly is a massive use case running so quickly is a massive use case running so quickly is a massive use case and I'm really excited to start and I'm really excited to start and I'm really excited to start implementing this in the organization implementing this in the organization implementing this in the organization I'm currently working for so yeah I'm currently working for so yeah I'm currently working for so yeah hopefully this has been a a good of a hopefully this has been a a good of a hopefully this has been a a good of a bit of an introduction to you about de bit of an introduction to you about de bit of an introduction to you about de containers I highly suggest you look containers I highly suggest you look containers I highly suggest you look into it and start using it in your own into it and start using it in your own into it and start using it in your own projects because it's super powerful projects because it's super powerful projects because it's super powerful thank you so much for watching and I thank you so much for watching and I thank you so much for watching and I hope to see you in the next one hope to see you in the next one hope to see you in the next one [Music]

Summary

This analysis explores Dev containers as a solution for consistent development environments, specifically addressing the challenge of installing multiple .NET runtimes on macOS or Linux. The key takeaway emphasizes how Dev containers allow you to define and package your entire development environment in code, ensuring that any project's specific tooling and dependencies are readily available within a container, thus eliminating setup hassles.

View original episode ↗