Skip main navigation

Overview of Docker Tools for Visual Studio

.
16.8
Hi, this is Colin from North West Cadence. In this short video, I’m going to give you a brief introduction to Docker tools for Visual Studio. To start off with, I’ve just kept things very simple with the code and gone to file, new project. And I created a new ASP.NET core web application. The application we have here is the standard web application that gets created from the project template. The only other thing I’ve done then after installing the Visual Studio tools for Docker is I’ve clicked my web project and selected add and Docker support. Adding Docker support added a few files to my project. There’s a Docker compose yaml file. There’s also a Docker compose debug yaml file.
64.1
You’ll see there’s two Docker files. One of them being debug, and one of them being release. And there’s a Docker task power source script. I had to modify one or two things in order to get this working smoothly, and you can read about my experiences at this URL.
81.4
Let’s open up the Docker file. There’s nothing particularly special about this Docker file. We’ve got from statement saying that we’re working from the dotnet core 100 image. We’re opening up a port. In this case, we’re specifying it as an arg, so that it can be configured whenever we run this container. Then we’re copying everything from the app folder to the app folder on the container, and finally, we’re calling dotnet test app.dll as the entry point. Perhaps a little bit more interesting is the debug Docker file. The debug Docker file has a lot of the same code, except it also copies on the clr debugger. This allows us to remote debug into the container from Visual Studio.
127
You’ll see the entry point is also a little bit more complicated since it’s expecting a remote entry call from the debugger. Let’s see this remote debugging in the container in action. When you add Docker support for your project, you’ll get a new configuration called Docker. We can launch the application using the Docker configuration. I’ll just press start using the Docker configuration. If we open up the output window, we’ll see exactly what Visual Studio is doing. It first does a dotnet restore and dotnet publish to create our replication. Then it does a Docker build using the file, and finally, runs a Docker compose app command to bring our container up.
172
Let’s quickly switch over to a Docker console. I’ll type in Docker ps to list all the running containers, and there, you can see we have a container running. Let’s do a Docker images, and here, we can see that we have a debug tag for our container that was built in Visual Studio, as well as a debug tag with the date and time. We can see from the Docker ps command that our container is running on port 5,000. Let’s open up our browser and browse to port 5,000. Here, you can see we get our template project running in the container.
213.6
Let’s set a breakpoint in Visual Studio in the about controller just to see that as we browse, we can actually debug, even though the application is running inside our container. Let’s go to the home controller, and we’ll set to breakpoint here in the about action.
234.1
And let’s click about, and here, you can see we’ve hit our break point. Now that we’re at our break point, we can step in, step over, and do any of the normal debugging operations we would do in our normal Visual Studio workflows. Let’s continue to run that, and you can see our about page. Let’s close that browser and stop debugging. Now, when we stop debugging, the container is still running.
264.2
Let’s do a Docker ps to confirm, so there’s a couple of ways that we can stop this. The easiest way is to run the clean command to clean the solution. This will stop any running containers and delete any images.
284
Now that the clean command has completed, let’s do another Docker ps, and you’ll see that we have no more running containers. And if we do Docker images, you can see that our debug images have been removed. And this video gave you a very brief overview and introduction to Docker tools for Visual Studio. In the next video, we’ll see how we can build and publish containers using vsts.

Expanding from the previous step, Colin demonstrates Docker’s tools for Visual Studio in a short video.

In this next step, we will learn how to build, push and run Docker Images Using VSTS.

This article is from the free online

Microsoft Future Ready: Fundamentals of DevOps and Azure Pipeline

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education