My Favorite Way To Handle Dev Environments | VS Code Devcontainers

Поділитися
Вставка
  • Опубліковано 6 чер 2024
  • A step-by-step walkthrough of using my favorite method to manage development environments: VS Code Devcontainers.
    No docker commands required!
    This is great for onboarding new people to your complex project or reproducing your work environment on a new machine. You can even use your devcontainers on the web through GitHub Codespaces.
    Let me know what you think in the comments. I spend several minutes talking at the beginning, so we don't move from the first screen for a while. 😅
    Docs for Dev Containers: code.visualstudio.com/docs/de...
    You can also find me on:
    Twitch: / dancancode
    Twitter: / dancancode
    00:00 Intro
    01:06 Why Dev Environments?
    02:19 Devcontainer Docs
    03:13 Install VS Code and Docker Desktop
    04:19 Example Starts
    06:23 Note for Windows Users
    07:33 Example Resumes
    19:10 Customize
    23:44 Where are the files kept?
    27:02 Use it nearly anywhere!
    29:18 Conclusion - thanks for watching
  • Наука та технологія

КОМЕНТАРІ • 86

  • @user-zt3vr3hs7u
    @user-zt3vr3hs7u Рік тому +52

    It was an impressive video. The length of 30 minutes may be confusing at first, but it's worth watching. Everything is explained in an accessible manner, logical and consistent. If all tutorials were at this level, we would live in a different, better world.

  • @sentient-machines
    @sentient-machines Рік тому +12

    Thank you for leaving the errors and solutions in. I also appreciate the somewhat informal style, it's like getting help from a friend, vs sitting in an overcrowded lecture hall. I learned a lot. Subscribed.

  • @NelCapeTown
    @NelCapeTown Рік тому +3

    So happy when the UA-cam algorithm finds gold for me. It is easy to get sidetracked into how the Universe sends you information you request on a philosophical level, but this explanation is so exactly what I needed and it popped up in my feed rather than specific search results. Spot on. Looking forward to seeing your other work.

  • @ksh6
    @ksh6 Рік тому +2

    Excellent video. It explained everything I wanted to know about this in a simple way. You have perfect voice and talent for these type of videos. Keep making, your videos will go viral over time.

  • @RajaSachithanantham
    @RajaSachithanantham Рік тому

    Thank you, Dan, for this incredibly informative and detailed tutorial on setting up a development environment using Visual Studio Code's Dev Containers. Your explanations were clear and easy to follow, and I appreciate how you addressed the challenges of reproducing the environment and onboarding new team members. The step-by-step instructions, along with the demonstrations, made it much easier for me to understand and implement this approach. I also liked how you highlighted the customization options and the integration with GitHub code spaces. This tutorial has been incredibly helpful, and I'm excited to apply this knowledge to my own projects. Keep up the great work!

  • @makoswebdev7382
    @makoswebdev7382 6 місяців тому +5

    Dan, your video was a lifesaver! I spent the entire day wrestling with the slow system problem you've mentioned , only to discover through your tutorial that the root of my troubles was cloning the repo into my local Windows file system. Your guidance was invaluable - thank you once more.

  • @ChrisCheng-en4nw
    @ChrisCheng-en4nw Рік тому

    Such a performance of a fantastic tutorial!!! Good job! Please bring more and more videos like this one! Thank you so much.

  • @bits_iot
    @bits_iot 5 місяців тому

    Great tutorial, you explained all the steps, mostly tutors or experienced people assume the viewer knows some steps which is not always true, I appreciate your extra efforts explaining each step thoroughly. Thanks.

  • @SouhaibD
    @SouhaibD Рік тому

    Clear and straight to the point. Thank you Dan!

  • @deandunn206
    @deandunn206 Рік тому

    Thanks for this, great overview of dev containers. Didn't know this existed! Will really help my workflow.

  • @detprest8975
    @detprest8975 Рік тому

    Had to endure watching a few other videos before I found yours. Clear, indepth and Concise the 30 mins flew past..

  • @Malix_off
    @Malix_off 4 місяці тому +1

    Perfect amount of edge-case covered, goated tutorial

  • @mykola2173
    @mykola2173 8 місяців тому

    This is magic! Exactly what I needed, thank you!

  • @digitaldisruptlabs
    @digitaldisruptlabs Рік тому

    Very clear and easy to follow. You are also very engaging! Thanks

  • @wattsfield1889
    @wattsfield1889 4 місяці тому

    Cool! I am totally looking deeper into Dev Containers to avoid installations pain for our team

  • @videotalks
    @videotalks Рік тому +1

    It was a wonderful video to learn about dev-containers. I'm a hobby developer and always into multiple projects with kinda same toolset. So, I was looking forward to getting another video from you where we can create one dev container in VS Code and use it for multiple projects? It would be a nice follow up to this one. Thanks.

  • @maqloch
    @maqloch Рік тому

    Realy nice tutorial. Helped a lot! Cheers!

  • @mahsaamiri9243
    @mahsaamiri9243 2 дні тому

    You explained it in an awesome way! Thanks

  • @geraldbullardjr
    @geraldbullardjr Рік тому

    Very VERY cool explanation THANKS!!!

  • @JamesQQuick
    @JamesQQuick 3 місяці тому

    Wow, I didn't know about this. Really cool!

  • @ahmedelrewaidy6049
    @ahmedelrewaidy6049 Рік тому +1

    Brilliant! Thank you.

  • @kenchang3456
    @kenchang3456 5 місяців тому

    Way excellent video, thanks. I'm going to give it a try.

  • @speppucci
    @speppucci Рік тому

    Awesome video, very clear!

  • @dekooks1543
    @dekooks1543 Рік тому

    This is top shelf stuff right there !!

  • @witoldwozniak6990
    @witoldwozniak6990 Місяць тому

    Very helpful, thanks!

  • @rujor
    @rujor 10 місяців тому

    Very nice walkthrough! It would be very useful to know how to setup container access to localhost, in cases where dev-servers (SQL/Redis etc.) are running there.

  • @frankfu1122
    @frankfu1122 Рік тому

    Thanks for sharing! I love it

  • @marioarmagni6498
    @marioarmagni6498 Рік тому

    uow, so good video! Thank you!

  • @slowjocrow6451
    @slowjocrow6451 2 місяці тому

    Finally I understand why and how to use this stuff 😅

  • @breezewang6344
    @breezewang6344 9 місяців тому

    Thanks for this great video. May I know which extension you used to draw flow-chart at around 7:00 minute?

  • @rishabhsaxena9357
    @rishabhsaxena9357 6 місяців тому +1

    Nice video!!
    I've some questions:
    1. How to share the dev container to a co-worker?
    2. If I add PostgreSQL as a database in my dev container, how will I access it using softwares like PgAdmin/Dbeaver?
    3. If I have my backend running on my local windows machine serving some APIs and my angular frontend application running in dev container, how will frontend communicate to the backend?

  • @user-xd5gd4pc9h
    @user-xd5gd4pc9h Рік тому

    I have to say "thanks" for your excellent video, I love it. I think the default Linux repo is OK! But, I just want to use different tools such as zsh, bat, riggrep, etc. Maybe, we can use nix and flakes to provide more config options in the same image for different projects. Do you know something similar or how to achieve that goal? Thanks a lot!

  • @ChadE1020
    @ChadE1020 Рік тому +1

    Thank you for showing this!!!!!!!!!!!!!!!......!!!!!!

  • @rangue
    @rangue Рік тому

    Very good! How do we share ssh key between the container and The host machine?

  • @mr_broombroom
    @mr_broombroom Рік тому +1

    Awesome video!
    Is there a way to connect from vscode to the dev container again besides using opening the recently opened in the welcome screen? When I try to do so, I can't see the files.
    Also: do I have to clone again when I destroyed the container?
    Keep up the good work!

    • @DanCanCode
      @DanCanCode  Рік тому +2

      Try the Remote Explorer icon on the activity bar? I think it lists containers, code spaces, ssh connections.
      You may have to re-clone if you destroyed it in docker. You could still get to the files in the volume it mounted if still available.
      Closing the window or turning off the container is not the same as destroying it. Just in case, thought I'd mention.

  • @RonWaller
    @RonWaller 10 місяців тому

    New to docker containers and container development. Curious can you customize the linux environment to run like your "home" setup? (similar terminal setup etc etc), also Can you create a "template" dev container when created the based is the same every time? (sort of pertaining to my pervious question. As to not be spending time setting up the environment to your liking for each and every dev container). I sure hope you get what I meant. lo.

  • @EngineeringVignettes
    @EngineeringVignettes Рік тому +1

    Thanks for the overview, it seems a good way to knock up a build environment if your needs can fit into a prebuild "canned" image.
    It seems it is running git operations in the container. How is it importing .git-credentials and .gitconfig into the container?
    On my hand-built containers i usually mount .gitconfig etc from my home dir and then I get access to those settings, PATs etc.
    It would also be interesting to see how the dev containers system overcomes the "docker user ID problem", we use a little trick on our containers to override the default user in the container with the outside user's uid (groupmod, usermod) when the container is first started..
    Cheers,

    • @DanCanCode
      @DanCanCode  Рік тому +1

      I think you can make custom Dockerfiles and use the system. I know you can modify them.
      It *might* be syncing git preferences through VS Code's GitHub sign in. I'm certain it's doing that for credentials. I haven't had to install the GitHub CLI or mess with persisting credentials on linux in all those other ways.
      Docs for how the user id thing is handled in devcontainers: code.visualstudio.com/remote/advancedcontainers/add-nonroot-user
      Love the Fallout vault boy avatar

  • @clusterdriven
    @clusterdriven 5 місяців тому +1

    @DanCanCode, let's say you are in a devcontainer, you do some work, run git add, commit, and push. Now you realize your ssh keys are missing inside the container as they only exist in your local machine and thus you can't push code. How would you go around this issue?

  • @alan-
    @alan- Рік тому +1

    That was a great tutorial, very clear and concise, thanks. I've subscribed and am going to commence binge-watching your other videos which all look interesting. React+Vite next...

  • @Adhocfan
    @Adhocfan Місяць тому

    great video. How would you do this for a nx monorepo that has 2 apps in side it with libs?

  • @marcjacobreyes
    @marcjacobreyes Рік тому +1

    Great Video

  • @phreakadelle
    @phreakadelle Рік тому +3

    Nice video! Thanks! Inspired me to get all that WSL stuff right. WIthout that, the performance can be very underwhelming...

    • @DanCanCode
      @DanCanCode  Рік тому +2

      Glad it helped! Yeah it really can get slow across the filesystems. Underwhelming indeed

  • @markortiz2679
    @markortiz2679 9 місяців тому

    @DanCanCode, what happen if we need most updated version of java for example but the available base workspace is still using an old version, is there a way to tell devcontainer to use latest or different version of java? Thanks

  • @utkarshkukreti239
    @utkarshkukreti239 6 місяців тому

    Fantastic

  • @aternous
    @aternous Рік тому

    Hi, with the method, how do I close VS Code (and stop the container after having checked in) and come back later on and automatically have the container started for me where I left off OR quickly start things up with a simple command to get back to where I was? Do I have to clone each time? Cant I start the container and VS Code automatically jump to the session in the container? What's the quickest way to get back to the state I left the application?

  • @CryptoBuilders
    @CryptoBuilders Місяць тому

    Hey dan, if i configured already WSL2 and Ubunto on my widnows OS, wouldnt be better to install directly docker desktop for linux instead of windows version?

  • @517Amit
    @517Amit Рік тому

    Nice video

  • @stuartbiggs1278
    @stuartbiggs1278 Рік тому

    When I try to clone the container, I get an error message saying "error occurred setting up the container. Is there any chance that you could look into this please?

  • @JeanPhilippeMaquestiaux
    @JeanPhilippeMaquestiaux 8 місяців тому

    Sometimes later... How do you specify the volume location e.g. /home/dev/projects/proj1

  • @Flackon
    @Flackon Рік тому +1

    So, to share your custom environment with other team members you would share the .devcontainer directory? How does it work?

    • @DanCanCode
      @DanCanCode  Рік тому

      I usually commit it to version control. So it is included when someone clones the project repo.

  • @b1chler
    @b1chler Рік тому

    cool video! thanks
    do you have experience with using it in a monorepo like turbo?

    • @DanCanCode
      @DanCanCode  Рік тому

      If the entire mono repo is in the container I think it shouldn't be any different. I do have a turborepo and sometimes use it in the dev container.

    • @b1chler
      @b1chler Рік тому

      @@DanCanCode the monorepo isn't running one container but every app is running in a container. meanin a docker compose and several docker files.
      :)

    • @BTCruiser2011
      @BTCruiser2011 Рік тому

      @@b1chler probably more complicated than it's worth then. Not sure how you'd get turborepo to communicate across the container boundary. I suppose you could try docker-in-docker, but sounds messy.

    • @pwii
      @pwii Рік тому

      @@b1chler You just need to have docker installed in the devcontainer and add a bind mount to the host's /var/run/docker.sock. The containers will be created on the host machine, but you might need to do some setup with docker networks if the app containers need to be accessible from the devcontainer.

  • @dnadgar
    @dnadgar 15 днів тому

    Hey Dan and Dan's community, I've been testing VSCode and Devcontainers in WSL/Docker for the last four days but I'm having a problem with "Build repository in devcontainer" using a Bitbucket Repository which hangs in the terminal when requesting permission to add the Bitbucket server to known_hosts. It just hangs and doesn't take the 'yes' keystrokes for input. Does anyone else have a solution?

  • @jimmydfgh8805
    @jimmydfgh8805 4 місяці тому

    I am trying to build an image using docker and the dockerfile is in the directory. docker extension is already installed. But when I build, the command line says "bash: docker: command not found". I don't know whether it is an image problem, sometimes I don't have the issue and sometimes I do. Any suggestions?

    • @jimmydfgh8805
      @jimmydfgh8805 4 місяці тому

      Ah, I just discovered that Docker is not installed by default in the image and I need to install myself. And the docker extension is a different thing altogether. Thank you.

  • @mikevaleriano9557
    @mikevaleriano9557 Рік тому +1

    a bit late, but how do you deal with updates to dependencies, how does it work?

    • @DanCanCode
      @DanCanCode  Рік тому

      Good question! Project dependencies are handled as normal, for instance you would run `npm install` in the terminal (it runs inside the container). If you update a dependency in the container's dockerfile, there's a command to rebuild the container. I think VS Code prompts you when a change is detected.

  • @rogalaharacz
    @rogalaharacz Рік тому +1

    What is the zsh theme you're using?

    • @DanCanCode
      @DanCanCode  Рік тому +1

      It's called powerlevel10k ! github.com/romkatv/powerlevel10k

    • @rogalaharacz
      @rogalaharacz Рік тому

      Thanks!

  • @davidhughes3834
    @davidhughes3834 Місяць тому

    Nice :) +1 sub

  • @couffin
    @couffin Рік тому

    Subscribe, like and share. This is a really great video!

  • @abdullahalrashidi497
    @abdullahalrashidi497 Рік тому

    when I install an extension and restart the container it doesn't persist so I need to reinstall it again! what's I'm doing wrong?

    • @DanCanCode
      @DanCanCode  Рік тому

      Hmm, I've not experienced this issue. I do know for some extensions you have to go to your extensions list and hit "install in remote". Could be worded differently, but some extensions need to run server-side.

  • @manee427
    @manee427 7 місяців тому

    How did you opened your terminal in windows with shortcut?

  • @Neo-zy5vg
    @Neo-zy5vg 11 місяців тому

    Checklist driven development

  • @esra_erimez
    @esra_erimez Рік тому +2

    I wish there was a JetBrains version of this

    • @DanCanCode
      @DanCanCode  Рік тому

      Agreed. The remote ssh and remote containers are one of reasons I eventually moved on from Pycharm

  • @clamhammer2463
    @clamhammer2463 Рік тому

    I can't use docker because of some setting in my bios. I can't find the setting to save my life.

    • @EngineeringVignettes
      @EngineeringVignettes Рік тому

      You need to enable hypervisor support in the BIOS?
      Also have to start the Windows 10/11 hypervisor (google Enable Hyper-V on windows)
      Both WSL and Docker will now use the Windows Hypervisor which makes things a lot easier now. The only possible glitch is if you are also running a VM, it may be incompatible.

  • @user-hu4yw5gg1q
    @user-hu4yw5gg1q 6 місяців тому

    I prefer to create my own Docker Compose with bind mounts to my repo code, and then use the VSCode's "attach to running container" functionality. Way easier, and without boiler plate. In this video they explain how easy it is to attach: ua-cam.com/video/8gUtN5j4QnY/v-deo.html&ab_channel=Code2020

  • @user-ed8vb9oe9p
    @user-ed8vb9oe9p 3 місяці тому

    i search all over the youtube there is no one tell the solution how we will manage "nodemon" with devcontainer, not just nodemon but same next.js, vue.js, laravel vite.