>> Welcome back. So in the last video,
we talked about what was Docker,
Docker file, and how to build and run those Docker things.
One of the questions I asked was,
is there something in Visual Studio that can help us out?
>> Yes, there is.
>> Okay. Awesome.
>> Yeah.
>> So what are the things that we've got
in Visual Studio as far as
tooling in this awesome IDE that can help us out?
>> So you can add Docker support to your project,
which automatically creates an appropriate Docker file for you.
You can edit your Docker files, of course.
You can also run your container directly from Visual Studio,
build and run your container from
Visual Studio including full debugging support.
>> That's fantastic. Let's see what that looks like here.
So I've got in my editor here,
just a basic ASP.NET Core web application.
Much like in the last video,
we showed a Console application.
This is a very simple Hello World application.
I'm assuming I'm going to right-click here on that project.
>> Yeah. Exactly.
>> Look for our tool and we've got "Add".
>> Yes, you want to click "Docker Support".
>> "Docker Support". All right.
So let's see what happens here.
It's going to ask me which OS I want to target.
So in Docker, we have Windows as we were using last time,
we were using a Windows Console app.
Here, I'm going to choose Linux because
I want to deploy this to the web.
>> Absolutely.
>> So let's use Linux. It looks
like it added a Docker file. That was pretty fast.
>> Yes.
>> So I'm going to choose "Dockerfile" here that looks like.
Well, that looks a little different,
almost scary than the last Docker file that we had.
What's going on with all these? It looks like I got
a multiple sections of
the Docker file that we explained here in the last video.
>> So you see the multiple formed statements and that means
that this is a multi-stage Docker file.
>> Okay.
>> What that means is that you can pull a base image,
you can do some things to it,
and then you can use
that intermediate container that
you've created to build another container image.
So this is commonly used because for example,
you can see here that you are
using a container image that contains the.NET Core SDK,
which is great when you're building a container,
especially on Linux where you need to
build the actual application inside the container,
but you might not want all that extra bloat of
the SDK for your final production image because you don't need it,
and you want that to be really small, and lean, and fast.
>> Okay.
>> So you can see that that very last block that
starts with "FROM base AS final" ends
up building a container image that does not have the SDK,
it simply has.NET Core in it,
and it's got your application, and then that's it.
It's got everything that you need to run and nothing you don't.
>> So if I'm looking through these multiple
layers as you're explaining it,
it appears as if I'm labeling
this first section as base and then at the last section down here,
I'm actually using that as the first set.
So I'm not actually going out to
another registry pool another one,
I'm using the one that's built as an intermediary.
>> Exactly.
>> Then, using again from publish.
So if I look back up in my other sections here,
I've got build AS publish.
It looks like I'm building a release version
of my web application and
then putting it into this publisher layer.
Then again, putting that will come all together at the very end.
>> Exactly.
>> Then, look at entry point here,
is a little different than the last one we
had in our last video we talked about.
We had.NET run.
We're just running all of the bits that we moved over,
and it looks like here
we're saying.NET, and then
running DockerWeb.dll.
So we're actually running the application as if
it was already ready to go.
>> Exactly.
>> That's the expectation.
>> Yes.
>> So you had mentioned that we can actually
run this right from this Visual Studio.
>> Yes, that's right.
>> So if I look up as I'm used to
doing in Visual Studio 2019 here,
I've got some other options.
I can run in IIS Express,
which I think we're used to doing all the time.
>> Yeah, that's local on your machine.
>> Then, we have DockerWeb, which runs in
our Kestrel instance locally.
Then also, now, I have a new option called Docker.
>> So when you add Docker support,
that gets added automatically.
>> Interesting. So I can just hit "Play" here.
>> Yes.
>> We'll see what that looks like.
So I'm seeing down here in our little console here,
our background task, that it's actually doing some things here.
Let's see if I put up the output here.
Wow, that was pretty fast. I think it's launching a browser
as you would expect and we get
our Hello World here, just like we would look out.
Now, I know normally that when I
run all my local machine and those other options,
my port is mostly something like 5,001 or something like that.
This instance, I'm getting another port.
Now, is this a port on my local machine,
or is this something that I'm getting out of my Docker container?
>> That's mapping to a port inside your Docker container.
>> Okay. Great. Now, you mentioned I can set a break point.
>> Yeah. You absolutely can.
Everything that you can do, debugging locally,
essentially, you can do when debugging on a container as well.
>> Okay. So I'm going to actually go over here to,
let's go and find where we can set a break point.
So we've got this Response.WriteAsync.
Let's just see if we can actually hit that break point.
So now, when I'm running this,
I'm assuming that I'm running inside of the container
and I have my debugger attached to that container.
>> Exactly.
>> So if I hit "Refresh" on
this and as expected, that's pretty great.
Awesome. So if I hit "Continue",
so that's awesome, I got my Hello World as expected.
But now that I have my application in
a container and working on
my local machine, how do we get it somewhere?
>> So Visual Studio has some built-in tools that allow
you to publish your container image
to a variety of different locations.
>> Well, that's great. Well, let's look at that in the next video.