Visual Studio 2019 Docker

  1. Enable Docker support during project creation in Visual Studio 2019 When you add or enable Docker support, Visual Studio adds a Dockerfile file to the project, that includes references to all required project from the solution. Add container orchestration support.
  2. Visual Studio 2019 Docker Tooling In this post I want to give an overview of what happens when you turn on the Docker tooling in Visual Studio 2019. If you're like me, you want to know a bit about what will happen under the hood before using a feature like this.

In Visual Studio 2019, I can debug a.NET Core console application with command line arguments using a configuration similar to below in launchSettings.json. Browse other questions tagged c# visual-studio docker.net-core command-line-arguments or ask your own question. With Visual Studio 2019, you can use Docker Compose, Kubernetes, and Service Fabric as container orchestration services.

Sponsored By

I've been spending a lot of time with Docker lately. Docker Desktop on Windows is great and getting better every day. Now that WSL2 (Windows Subsystem for Linux) is rolling out stable over the coming weeks and Docker Desktop supports WSL to host Linux containers directly, I'm finding myself using Visual Studio to develop my sites under Docker.

Visual Studio Container Tools are actively improving as well and the latest release is pretty sweet. You likely already HAVE this as the Containers tool window is now included in Visual Studio 2019 starting with version 16.4 Preview 2 and above!

NOTE: Be sure to check out the Visual Studio Code Docker Extension as well!

First thing that is impressive is that Visual Studio now tries to help you get to a successful place with helpful guidance, as sometimes set up can be daunting.

When you create or open a Docker-enabled project:

Wsl2
  • VS container tools help you install Docker Desktop
  • VS container tools make sure Docker Desktop is running

You've got the Container Tools already if you've installed the Web or Azure Workload in Visual Studio 2019 and it is included in the free Visual Studio 2019 Community!

You can Docker-enable a project with a checkbox when you create it OR you can right click Add Docker Support after the fact.

When working with .NET Core the Container Tools will make a great multi-stage Dockerfile that encapsulates best practices. It uses Docker layering to build within Docker using the .NET SDK but then publishing into a smaller runtime container for the smallest possible resulting image for maximum density.

Multi-container Debugging

Debugging real systems with multiple containers has been a challenge in the past. VS2019 now has Container Orchestrator Support built-in. This screenshot shows Docker Compose appearing itself as a Debug Target within the standard VS2019 toolbar!

Once you have a bunch of containers running, the Containers Tool finds a nice balance between showing you the text logs and getting out of your way but also giving you a GUI to start and stop and manage multiple running containers.

You can see below the images I have, the Solution Containers. I can even right click and Attach to Process within a running Linux container! Again, all using WSL2 and wicked fast.

Coming soon to Visual Studio! Native WSL2 debugging

I like my containers BUT if you just want to dev on Linux directly (no containers) then this is one of the 'coming soons' that you'll be the most excited about - WSL 2 Debugging! Coming soon to the Marketplace as a preview with a plan to ship in future Visual Studio tooling releases, you'll be able to just select WSL2 (Linux) as a compilation and debug target! That means dev/test/run native Linux on Windows right from VS.

Visual Studio 2019 Docker Free

Remember that WSL2 uses a real Linux kernel so there's no emulators here. The WSL2 Linux starts up in about a second and you'll be debugging FAST. WSL2 is rolling out now!

That means breakpoints and full debugging on Linux from Visual Studio 2019 on Windows. Scott Hunter and I talked about this and showed a demo in our 'Journey to One .NET' talk at BUILD this year that you can watch free here!

Visual Studio 2019 Docker Debug

If you want all these nice Container Tools either install VS2019 or just run the Visual Studio Installer and UPDATE your existing installation.

Sponsor: This week's sponsor is...me! This blog and my podcast has been a labor of love for over 18 years. Your sponsorship pays my hosting bills for both AND allows me to buy gadgets to review AND the occasional taco. Join me!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

Visual Studio 2019 Docker Port Mapping

Visual studio 2019 docker-composeVisual
AboutNewsletterGoogle uses cookies and data to:
  • Deliver and maintain services, like tracking outages and protecting against spam, fraud, and abuse
  • Measure audience engagement and site statistics to understand how our services are used
If you agree, we’ll also use cookies and data to:
  • Improve the quality of our services and develop new ones
  • Deliver and measure the effectiveness of ads
  • Show personalized content, depending on your settings
  • Show personalized or generic ads, depending on your settings, on Google and across the web
For non-personalized content and ads, what you see may be influenced by things like the content you’re currently viewing and your location (ad serving is based on general location). Personalized content and ads can be based on those things and your activity like Google searches and videos you watch on YouTube. Personalized content and ads include things like more relevant results and recommendations, a customized YouTube homepage, and ads that are tailored to your interests.Visual Studio 2019 Docker

Click “Customize” to review options, including controls to reject the use of cookies for personalization and information about browser-level controls to reject some or all cookies for other uses. You can also visit g.co/privacytools anytime.