Visual Studio Code Can Do That?

Developing Remote Containers

Burke Holland

Burke Holland

Visual Studio Code Can Do That?

Check out a free preview of the full Visual Studio Code Can Do That? course

The "Developing Remote Containers" Lesson is part of the full, Visual Studio Code Can Do That? course featured in this preview video. Here's what you'd learn in this lesson:

Burke demonstrates how to access Docker remote containers using VS Code. When a container is first built, the process can take some time.


Transcript from the "Developing Remote Containers" Lesson

>> Burke Holland: What we want to do here is we want to make it so that we can run this application here, which is an Azure Functions project, inside of a container. Because in order for you to run an Azure Functions project, you have to have some very specific things.

You need to have the .NET core CLI. You have to have that installed. You have to have the Azure Functions core tools installed, you have to have the Azure Functions extension installed. This is before you can even think about running the application. So instead, what we wanna do is create a container which already has those things.

And then anybody else can run them as well using remote containers. So here's how we do that. We've got our project here. Let's go ahead and turn this thing into a remote container project. So I'm gonna do Cmd+Shift+P, Remote-Containers. And what I'm gonna say is Add Development Configuration Files for a Container.

Now, it will ask us which project and then it wants to know which on of this pre-built environments do you want? So it's got a bunch to start out with. If you go through here, you can see there's F#, there's Java, there's Go, there's Node, there's Perl, there's PowerShell, and Python of course down here at the bottom.

Swift, just in case you want to develop swift. These are pre-configured containers that you can use. So what we want is Azure Functions & Node LTS. And then what happens is it gives us two files over here. We get a devcontainer file, which specifies information about the development environment.

And then look what we get. A Docker file. Now, if we look at this Docker file, it looks a little bit wordy. So you can see here, we've got, it's running some updates. It's installing some things. It's installing Git. I don't know what these things are. I believe they're Linux utilities that we need to actually make this thing run.

And then down here look installing .NET Core and the Azure CLI and setting up all the correct permissions, configuring all the pads correctly. All right cleaning up, and then I don't know what that does switch back to dialogue for any ad-hoc use of apt-get. Okay, we'll do. All right now that we've got this we actually need to create the container.

So we have the dev container folder. How do we open this project inside of the container? How do we use that container as our development environment? Back at our Command Prompt I'm just gonna move into the Start folder here. And I'm gonna open a new instance of VS code.

>> Burke Holland: All right. So now I'm inside the start project. And what we want to do is open this project inside of our container. So what we're going to do is look at my party parrots going nuts up there. We're going to do this right here, click on this little icon and we're going to say Remote-Containers.

Reopen folder in containers.
>> Burke Holland: Now it says installing dev container. If we go to details, and you can see it's pulling down all these things. It's running all these commands. It's installing these things for Linux, it's setting all these values. It's going to pull down and install the .NET Core framework that we need to run this, which it's doing right now.

And the first time that you open a new dev container, the first time you create one, it takes a while because it has to pull all this stuff down from the cloud. After you do it the first time, it gets a whole lot faster because it's all cached locally and you don't have to pull it down anymore.

>> Burke Holland: If the container file changes, and it's not the same as what's on your local machine anymore, when you go to open the container, it will actually refresh and rebuild and get you the newest version so that's always current. You can see it's got core. I didn't even know you needed core to run this.

I guess you do. So we'll just let this thing finish here, unpacking Azure Functions Core Tools.
>> Burke Holland: Let it install all this stuff. While this is happening, I'll tell you about the third flavor of remote development that we're not gonna talk about, and that's for the WSL. So this is a very specific thing to Windows.

Windows has the Windows subsystem for Linux, and what it does is it gives you a Linux command prompt on Windows. The problem is that those two file systems are separate, so people who use the WSL know this, people who don't this is going to sound a little weird to you.

But if you create a file In the WSL you can't even edit that file from the Windows file system. So the problem is that when you open a project from the WSL in VS code where does VS code run? On the Windows side. Where are your files? On the Linux side, that's a problem.

And so what it does now is it remotes in and allows you to develop actually inside the WSL which is a much improved experience for people that are using the Windows subsystem. We're not gonna go over that here but if you are on Windows you should check out and make sure that you have the remote containers or remote for WSL installed.

It will make your life much happier. All right, I think we are getting close to getting this container built.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now