Visualstudio Containers Visualstudio
Visualstudio Containers Visualstudio
Container Tools
e OVERVIEW
Get started
f QUICKSTART
g TUTORIAL
c HOW-TO GUIDE
c HOW-TO GUIDE
Customize containers
i REFERENCE
Prerequisites
Docker Desktop or Podman Desktop
Visual Studio , or for Podman support, Visual Studio 2026 , with the [Link] and web
development, Azure development workload, and/or .NET desktop development
workload installed.
To publish to Azure Container Registry, an Azure subscription. Sign up for a free trial .
If you just want a container for a single project, without using orchestration, you can do that by
adding container support. You can choose Docker or Podman as a container platform, and
easily switch between them without changing the project. The next level is Container Compose
support, which adds appropriate support files for Docker Compose. (Podman Compose is not
supported.)
When you add container support to a .NET 7 or later project, you have two container build
types to choose from for adding container support. You can choose to add a Dockerfile to
specify how to build the container images, or you can choose to use the built-in container
support provided by the .NET SDK.
The Containers window lets you view running containers, browse available images, view
environment variables, logs, and port mappings, inspect the filesystem, attach a debugger, or
open a terminal window inside the container environment. See Use the Containers window.
To create a project with container support, or add container support to an existing project, see
Add support for containers.
7 Note
Docker's licensing requirements might be different for different versions of Docker
Desktop. Refer to the Docker documentation to understand the current licensing
requirements for using your version of Docker Desktop for development in your situation.
To use Podman containers, start podman from the CLI, and open your solution in Visual Studio.
By default, Container Tools automatically detects whether Podman or Docker is running, and
use the currently active container runtime when you start the app. To configure the container
runtime manually, go to Tools > Options > Container Tools > Container Runtime and select
Podman or Docker. The default setting is Auto, which means Visual Studio tries to detect the
currently active container runtime. Close the Tools > Options window to commit the setting
change.
Containers window
The Containers window lets you view containers and images on your machine and see what's
going on with them. You can view the filesystem, volumes mounted, environment variables,
ports used, and examine log files.
Open the Containers window by using the quick launch (Ctrl+Q) and typing containers . You
can use the docking controls to put the window somewhere. Because of the width of the
window, it works best when docked at the bottom of the screen.
Select a container, and use the tabs to view the information that's available. To check it out, run
your Docker-enabled app, open the Files tab, and expand the app folder to see your deployed
app on the container.
For more information, see Use the Containers window.
To add container orchestrator support using Docker Compose, right-click the application in
Solution Explorer, and then select Add > Container Compose Support.
After you add container orchestrator support to your project, you see a Dockerfile added to the
project (if there wasn't one there already) and a docker-compose folder added to the solution
in Solution Explorer, as shown here:
If [Link] already exists, Visual Studio just adds the required lines of configuration
code to it.
Repeat the process with the other projects that you want to control using Docker Compose.
If you work with a large number of services, you can save time and computing resources by
selecting which subset of services you want to start in your debugging session. See Start a
subset of Compose services.
7 Note
For Service Fabric, see Tutorial: Deploy your [Link] Core app to Azure Service Fabric by using
Azure DevOps Projects.
Next steps
For further details on the services implementation and use of Visual Studio tools for working
with containers, read the following articles:
Prerequisites
Docker Desktop or Podman Desktop .
Visual Studio , or for Podman support, Visual Studio 2026 , with the [Link] and web
development, Azure development workload, and/or .NET desktop development
workload installed.
To publish to Azure Container Registry, an Azure subscription. Sign up for a free trial .
To use Podman as the container platform, download Podman Desktop for Windows, and
then follow the tutorial at Podman for windows to initialize and start a Podman machine.
To change the container type used by Docker Desktop, right-click the Docker icon (whale)
in the Taskbar and choose either Switch to Linux containers or Switch to Windows
containers.
2 Warning
If you switch the container type after you create the Visual Studio project, the Docker
image files might fail to load.
2. Create a new project using the [Link] Core Web App template.
3. On the Create new web application screen, make sure the Enable container Support
checkbox is selected.
4. Select the type of container you want (Windows or Linux) and select Create.
Dockerfile overview
Visual Studio creates a Dockerfile in your project, which provides the recipe for how to create a
final Docker image. For more information, see the Dockerfile reference for details about the
commands used in the Dockerfile.
Dockerfile
#See [Link] to learn how to customize your debug
container and how Visual Studio uses this Dockerfile to build your images for faster
debugging.
# This stage is used when running from VS in fast mode (Default for Debug
configuration)
FROM [Link]/dotnet/aspnet:8.0 AS base
USER $APP_UID
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
# This stage is used to build the service project
FROM [Link]/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["MyWepApp/[Link]", "MyWebApp/"]
RUN dotnet restore "./MyWebApp/./[Link]"
COPY . .
WORKDIR "/src/MyWebApp"
RUN dotnet build "./[Link]" -c %BUILD_CONFIGURATION% -o /app/build
# This stage is used to publish the service project to be copied to the final stage
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./[Link]" -c %BUILD_CONFIGURATION% -o /app/publish
/p:UseAppHost=false
# This stage is used in production or when running from VS in regular mode (Default
when not using the Debug configuration)
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "[Link]"]
The preceding Dockerfile is based on the Microsoft syndicates container catalog .NET 8
image and includes instructions for modifying the base image by building the project named
MyWebApp and adding it to the container.
When the new project dialog's Configure for HTTPS checkbox is checked, the Dockerfile
exposes two ports. One port is used for HTTP traffic; the other port is used for HTTPS. If the
checkbox isn't checked, a single port (80 or 8080) is exposed for HTTP traffic.
When targeting .NET 8 and later, you have the benefit of being able to run your app more
securely, as a normal user, rather than with elevated permissions. The default Dockerfile
generated by Visual Studio for .NET 8 projects is configured to run as a normal user. To enable
this behavior on an existing project, add the line USER app to the Dockerfile in the base image.
Also, because port 80 is restricted for normal users, expose ports 8080 and 8081 instead of 80
and 443. Port 8080 is used for HTTP traffic, and port 8081 is used for HTTPS. To run as a normal
user, the container must use a .NET 8 base image, and the app must run as a .NET 8 app. When
configured correctly, your Dockerfile should contain code as in the following example:
Dockerfile
FROM [Link]/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
The default templates use the environment variable APP_UID for the identity of the normal user.
Debug
Select Docker from the debug dropdown list in the toolbar, and start debugging the app. You
might see a message with a prompt about trusting a certificate; choose to trust the certificate
to continue.
The Container Tools option in the Output window shows what actions are taking place. The
first time, it might take a while to download the base image, but it's faster on subsequent runs.
After the build completes, the browser opens and displays your app's home page. In the
browser address bar, you can see the localhost URL and port number for debugging.
7 Note
If you need to change ports for debugging, you can do that in the [Link]
file. See Container Launch Settings.
Containers window
You can use the Containers window to view running containers on your machine and other
images you have available.
Open the Containers window by using the search box in the IDE (press Ctrl+Q to use it), type
in container , and choose the Containers window from the list.
You can mount the Containers window in a convenient place, such as below the editor, by
moving it around and following the window placement guides.
In the window, find your container and step through each tab to view the environment
variables, port mappings, logs, and the filesystem.
For more information, see Use the Containers window.
1. Change the configuration dropdown list to Release and build the app.
5. Fill in your desired values in the Create a new Azure Container Registry.
ノ Expand table
DNS Prefix Globally unique Name that uniquely identifies your container registry.
name
Registry A location close to Choose a Location in a region near you or near other
Location you services that can use your container registry.
6. Select Create. The Publish dialog now shows the created registry.
7. Choose Finish to complete the process of publishing your container image to the newly
created registry in Azure.
Next steps
You can now pull the container from the registry to any host capable of running Docker
images, for example Azure Container Instances.
Additional resources
Container development with Visual Studio
Create a multi-container app with Docker Compose
Troubleshoot Visual Studio development with Docker
Visual Studio Container Tools GitHub repository
The completed sample that you create in this tutorial can be found on GitHub at
[Link] in the folder docker/ComposeSample.
Prerequisites
Docker Desktop
Visual Studio with the [Link] and web development, Azure development workload,
and/or .NET cross-platform development workload installed. This installation includes
the .NET SDK.
Don't select Enable container support. You add container support later in the process.
Create a Web API project
1. Add a project to the same solution and call it MyWebAPI. Select API as the project type,
and clear the checkbox for Configure for HTTPS.
7 Note
In this design, we're only using HTTPS for communication with the client, not for
communication from between containers in the same web application. Only
WebFrontEnd needs HTTPS and the code in the examples assumes that you have
cleared that checkbox. In general, the .NET developer certificates used by Visual
Studio are only supported for external-to-container requests, not for container-to-
container requests.
2. Add support for Azure Cache for Redis. Add the NuGet package
[Link] (not [Link] ). In
[Link], add the following lines, just before var app = [Link]() :
C#
[Link](options =>
{
[Link] = "redis:6379"; // redis is the container name of
the redis service. 6379 is the default port
[Link] = "SampleInstance";
});
C#
using [Link];
using [Link];
C#
using [Link];
using [Link];
using [Link];
namespace [Link]
{
[ApiController]
[Route("[controller]")]
public class CounterController : ControllerBase
{
private readonly ILogger<CounterController> _logger;
private readonly IDistributedCache _cache;
[HttpGet(Name = "GetCounter")]
public string Get()
{
string key = "Counter";
string? result = null;
try
{
var counterStr = _cache.GetString(key);
if ([Link](counterStr, out int counter))
{
counter++;
}
else
{
counter = 0;
}
result = [Link]();
_cache.SetString(key, result);
}
catch(RedisConnectionException)
{
result = "Redis cache is not found.";
}
return result;
}
}
}
The service increments a counter every time the page is accessed and stores the counter
in the cache.
Add code to call the Web API
1. In the WebFrontEnd project, open the [Link] file, and replace the OnGet method
with the following code.
C#
public async Task OnGet()
{
// Call *mywebapi*, and display its response in the page
using (var client = new [Link]())
{
var request = new [Link]();
// A delay is a quick and dirty way to work around the fact that
// the mywebapi service might not be immediately ready on startup.
// See the text for some ideas on how you can improve this.
// Uncomment if not using healthcheck (Visual Studio 17.13 or later)
// await [Link](10000);
7 Note
In real-world code, you shouldn't dispose HttpClient after every request. For best
practices, see Use HttpClientFactory to implement resilient HTTP requests.
The URI given references a service name defined in the [Link] file. Docker
Compose sets up a default network for communication between containers using the
listed service names as hosts.
The code shown here works with .NET 8 and later, which sets up a user account in the
Dockerfile without administrator privileges, and exposes port 8080 because the HTTP
default port 80 is not accessible without elevated privilege.
2. In the [Link] file, add a line to display ViewData["Message"] so that the file looks
like the following code:
CSHTML
@page
@model IndexModel
@{
ViewData["Title"] = "Home page";
}
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<p>Learn about <a href="/aspnet/core">building Web apps with [Link]
Core</a>.</p>
<p>@ViewData["Message"]</p>
</div>
This code displays the value of the counter returned from the Web API project. It
increments every time the user accesses or refreshes the page.
3. Visual Studio 17.12 and later Choose the scaffolding options for the WebFrontEnd
project.
Visual Studio 17.11 and earlier Choose your Target OS, for example, Linux.
Visual Studio creates a [Link] file and a .dockerignore file in the docker-
compose node in the solution, and that project shows in boldface font, which shows that
it's the startup project.
The [Link] appears as follows:
YAML
services:
webfrontend:
image: ${DOCKER_REGISTRY-}webfrontend
build:
context: .
dockerfile: WebFrontEnd/Dockerfile
The .dockerignore file contains file types and extensions that you don't want Docker to
include in the container. These files are generally associated with the development
environment and source control, not part of the app or service you're developing.
Look at the Container Tools section of the output pane for details of the commands
being run. You can see the command-line tool docker-compose is used to configure and
create the runtime containers.
4. In the Web API project, again right-click on the project node, and choose Add >
Container Orchestrator Support. Choose Docker Compose, and then select the same
target OS.
7 Note
In this step, Visual Studio will offer to create a Dockerfile. If you do this on a project
that already has Docker support, you are prompted whether you want to overwrite
the existing Dockerfile. If you've made changes in your Dockerfile that you want to
keep, choose no.
Visual Studio makes some changes to your docker-compose YML file. Now both services
are included.
YAML
services:
webfrontend:
image: ${DOCKER_REGISTRY-}webfrontend
build:
context: .
dockerfile: WebFrontEnd/Dockerfile
mywebapi:
image: ${DOCKER_REGISTRY-}mywebapi
build:
context: .
dockerfile: MyWebAPI/Dockerfile
5. Add the cache to the [Link] file:
yml
redis:
image: redis
Make sure the indentation is at the same level as the other two services.
6. (Visual Studio 17.13 or later) The dependent services demonstrate a common problem.
The HTTP request in the front end's main page could run immediately on application
launch, before the mywebapi service is ready to receive web requests. If you're using Visual
Studio 17.13 or later, you can use the Docker Compose features depends_on and
healthcheck in [Link] to make the projects start in the right sequence, and
have them be ready to serve requests when required. See Docker Compose - Startup
order .
yml
services:
webfrontend:
image: ${DOCKER_REGISTRY-}webfrontend
depends_on:
mywebapi:
condition: service_healthy
build:
context: .
dockerfile: WebFrontEnd/Dockerfile
mywebapi:
image: ${DOCKER_REGISTRY-}mywebapi
depends_on:
redis:
condition: service_started
healthcheck:
test: curl --fail [Link] || exit 1
interval: 20s
timeout: 20s
retries: 5
build:
context: .
dockerfile: MyWebAPI/Dockerfile
redis:
image: redis
In this example, the health check uses curl to verify that the service is ready to process
requests. If the image you're using doesn't have curl installed, add lines to the base
stage of the MyWebAPI Dockerfile to install it. This step requires elevated privileges, but
you can restore the normal user privileges after installing it as shown here (for the Debian
images used in this example):
Dockerfile
USER root
RUN apt-get update && apt-get install -y curl
USER $APP_UID
7 Note
If you're using a Linux distro, like Alpine, that doesn't support apt-get , try RUN apk -
-no-cache add curl instead.
These Docker Compose features require a property setting in the Docker Compose
project file ( .dcproj ). Set the property DependencyAwareStart to true:
XML
<PropertyGroup>
<!-- existing properties -->
<DependencyAwareStart>true</DependencyAwareStart>
</PropertyGroup>
This property activates a different way of starting the containers for debugging that
supports the service dependency features.
With these changes, the webfrontend service will not start until mywebapi starts and
successfully handles a web request.
7. The first project that you add container orchestration to is set up to be launched when
you run or debug. You can configure the launch action in the Project Properties for the
Docker Compose project. On the Docker Compose project node, right-click to open the
context menu, and then choose Properties, or use Alt+Enter. For example, you can
change the page that is loaded by customizing the Service URL property.
8. Press F5. Here's what you see when launched:
9. You can monitor the containers using the Containers window. If you don't see the
window, use the search box, press Ctrl+K, Ctrl+O, or press Ctrl+Q. Under Feature search,
search for containers , and choose View > Other Windows > Containers from the list.
10. Expand the Solution Containers node, and choose the node for your Docker Compose
project to view combined logs in the Logs tab of this window.
You can also select the node for an individual container to view logs, environment
variables, the filesystem, and other details.
The Manage Docker Compose Launch Settings dialog comes up. With this dialog, you
can control which subset of services is launched during a debugging session, which are
launched with or without the debugger attached, and the launch service and URL. See
Start a subset of Compose services.
Choose New to create a new profile, and name it Start Redis . Then, set the Redis
container to Start without debugging, leave the other set to Do not start, and choose
Save.
Then create another profile Start My Services that doesn't start Redis, but starts the
other two services.
(Optional) Create a third profile Start All to start everything. You can choose Start
without debugging for Redis.
2. Choose Start Redis from the dropdown list on the main Visual Studio toolbar. The Redis
container builds and starts without debugging. You can use the Containers window to see
that it's running. Next, choose Start My Services from the dropdown list and press F5 to
launch them. Now you can keep the cache container running throughout many
subsequent debug sessions. Every time you use Start My Services, those services use the
same cache container.
Next steps
Look at the options for deploying your containers to Azure. If you're ready to deploy to Azure
Container Apps, see Deploy a multicontainer app to Azure Container Apps.
See also
Docker Compose
Container Tools
The process involves a few steps using Visual Studio and the Azure portal. You can also use the
Azure CLI to perform these actions, but that's beyond the scope of this tutorial. First, we use
the app you built using the Create a multi-container app, and deploy it using the Publish
process. Visual Studio walks you through the steps to create the first container app, a container
app environment, as well as create a container registry to store the container images. You then
run through the Publish process again with the other container app. You specifically must
choose the same container app environment in the Publish process. Finally, you need to
configure the Redis cache to work with the Azure Redis Cache service. You modify the cache
configuration code and republish the Web API. Then, you configure the permissions to grant
the app's system-assigned managed identity access to the cache.
Prerequisites
An Azure subscription. Sign up for a free trial .
Visual Studio with the Azure development and [Link] and web development
workloads installed.
The MulticontainerSample project at [Link]
samples in the docker folder. The sample solution contains two projects, the Web API
backend and the [Link] Razor front end, as you created in another tutorial. You can also
create the two projects from scratch, since they are very simple modifications of the
default templates, by following that tutorial. You can skip the Docker Compose steps.
2. Choose the target Azure, and then select Azure Container Apps.
3. If you're not already signed in with an account that is associated with an Azure
subscription, you can sign in now, or change the tenant if you need to.
4. On the screen where you specify a container app, select Create new to create a new
container app.
5. On the Create Azure Container app page, enter details such as the resource group. For
this step, you create a new resource group, a new container environment, and a new
container registry.
It might take a little while to create the resources. When it completes, click Next to move
to the next step.
6. In the next step, you create a container registry. If you create a new container registry,
you're asked for a few details. You can choose the same region and resource group as the
container app.
7. The next step asks you to choose the container build type. Choose .NET SDK if you don't
have a Dockerfile, or Docker Desktop if you do.
8. For the deployment type, choose Publish (generate pubxml file) to create a publish
profile.
9. Select Finish to complete the Publish process, and create a Publish profile. If you see a
prompt about extra configuration to access the published container, choose Yes.
You see a page that shows the activity in Azure, and when you close it, the Publish screen
now has your container app's information, such as the URL for ingress to the web API.
Click the Publish button to publish to the Azure container app. Visual Studio requests that
the Azure resources be created, and starts the publish process for the WebAPI container
app.
Visual Studio might try to load the page for the new container app, but this wouldn't be
expected to work at this stage.
Now that you've published once, you've created a Publish profile ( .pubxml file), so you don't
have to repeat these steps the next time you publish. Just click the Publish button on this
screen, unless you want to start over, or change any of the Azure resources you specified.
Later, you'll use the Azure portal to make some further configuration changes for the Ingress
and to support the Azure Redis Cache, but first, in the next section, you publish the web front
end.
C#
2. In Solution Explorer, right-click on the project node for the Webfrontend project, and
select Publish. On the next screen, select Create new to create a new container app.
3. On the Create new Azure container app screen, choose the same resource group and the
same container environment that you created when you published the Web API project.
4. Important! Select the same container registry that you created previously.
5. Choose the same options as you did for the Web API for the other steps. The container
build type is Docker Desktop, and the deployment type is Publish (generates pubxml
file).
6. Select Finish to complete the Publish process, and create a Publish profile. You see a page
that shows the activity in Azure, and when you close it, the Publish screen now has your
container app's information, such as the URL for ingress to the Webfrontend app.
a. On the Ingress screen, set Ingress traffic to Limited to Container Apps Environment.
This means that only the Webfrontend can send requests. Even Visual Studio won't be
able to access this service, for example, when you complete the publish process, and
Visual Studio tries to load the page, you get an error in the browser instead of
accessing the service. This is expected.
b. Check the Ingress port (it should be 8080). You're using HTTP for the web API call and
you can directly reference the container app by name in the request URI. The fully
qualified domain name (FQDN) generated by Azure Container apps uses an HTTPS URL
(as displayed in Visual Studio on the Publish screen), but internal traffic can bypass
that.
c. For the Webfrontend Ingress, you can accept the defaults. The Target port is 8080,
because the Ingress handles all requests securely using the FQDN and HTTPS (or HTTP
to HTTPS redirection), and forwards them to the Webfrontend using HTTP on container
port 8080.
1. In the Azure portal, open the Web API container app you created previously. Open the
Service Connector screen, and select Create. The Create connection section appears.
2. On the Create connection screen, enter the Service type as Cache for Redis, and choose
Create new to create a new Redis cache.
3. Choose a cache, or follow the Create new link to create a cache. If you create a new
cache, you might have to return to the container app and Service Connector and repeat
the previous steps to create the connection.
4. For the database, choose "0" to create the first numbered database for this cache.
5. Move to the Authentication tab. Choose System-assigned managed identity. Accept all
other defaults, and select Create. This creates the connection to the cache.
6. Back in the Service Connector section of the Web API container app, refresh to see the
newly connected cache (if you don't see it already), and select the checkbox next to the
cache. Select Validate to check the status of the connection. You can expand the cache
node to see the values for the environment variables for that Azure cache. For the
purposes of this tutorial, you only need AZURE_REDIS_HOST, but you can use the others
in real-world code or for a more complete configuration. Use the values here to set the
environment variables in the Dockerfile, as described in the next section, so that Web API
can connect to the cache.
For more information, see Quickstart: Create a Service Connection for Azure Container Apps
from the Azure portal.
1. In the Azure portal, open the page for the Azure Redis Cache, and select Access Control
(IAM).
2. Select Add > Add Role Assignment. The Add role assignment page opens.
3. Select the Members tab, and choose managed identity.
4. Select Select members. The Select members page opens, and select System-assigned
managed identity.
5. Select Container App, and choose the Web API container app.
6. In the Role tab, choose Redis Cache Contributor.
7. Select Review and assign. The system processes the request.
8. Open Role assignments to see the system-assigned managed identity under the Redis
Cache Contributor role.
The next step is to modify the cache configuration in the Web API client to use the
DefaultAzureCredential , which is the recommended way to authenticate when you use the
system-assigned managed identity. Anyone accessing the application externally isn't required
to have specific user-level role assignments to access the resources via this form of identity
management. For more information, see Integrate Azure Redis Cache - System-assigned
managed identity.
For Azure Redis Cache, you set an environment variable AZURE_REDIS_HOST with the connection
information, and then read it in the startup code to connect to Azure Redis Cache, and
configure the cache.
1. In Visual Studio, in the Web API project, add a reference to the NuGet packages Azure
Identity and [Link] .
C#
using [Link];
using [Link];
3. Update the configuration code for the Redis Cache. Delete the old code and replace it
with the following code. You can review the comments later and uncomment any optional
code to suit your own more advanced scenarios.
C#
// Check the environment variable for the Redis cache host name
var cacheHostName = [Link]("AZURE_REDIS_HOST");
if ([Link](cacheHostName))
{
throw new InvalidOperationException("The environment variable
'AZURE_REDIS_HOST' is not set.");
}
[Link](options =>
{
[Link] = configurationOptions;
[Link] = "SampleInstance";
});
The authentication method you set earlier when you created the cache connection is
system-assigned managed identity, so the code here is consistent with that choice. If you
want to use another authentication methods as well, you need to make changes to the
code here. See Integrate Azure Redis Cache - System-assigned managed identity.
4. If you have a Dockerfile, update the base stage of the Dockerfile to define the
environment variable AZURE_REDIS_HOST . You get the host from the Azure portal, when
you create the Azure Redis Cache, or from the Service Connector section of the Web API
container app page in the portal (see previous section).
Dockerfile
ENV AZURE_REDIS_HOST [Link]
(Optional) You can define other configuration options in environment variables, for
example, AZURE_REDIS_PORT which is usually 6380. For simplicity, this value is hardcoded
instead of using an environment variable. You might also wish to set
ASPNETCORE_ENVIRONMENT to Development.
If you're using the .NET SDK container build type (without a Dockerfile), you can set the
environment variable in [Link] under profiles > http .
JSON
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "[Link]
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"AZURE_REDIS_HOST": "[Link]"
}
}
5. You're ready to publish and verify these changes. Select the Publish button on the
Publish screen. Visual Studio will attempt to load the page, but this fails because the Web
API container app is not accessible to requests outside of the container app environment.
Before you can run the application with the Azure Redis Cache, you need to set up the
managed identity with the right permissions to access the cache.
Tip
Azure Container Apps seeks to maximize uptime of your services. If anything goes wrong
with one of the services, such that it fails a health probe, Azure Container Apps won't set it
as the active revision and use it serve requests. As a consequence, during the
development and testing process, you might occasionally find that the latest changes
you've made aren't reflected in the live site. In the Azure portal, select Revisions and
replicas to view the status of your latest published revision. From there, you can open logs
to help troubleshoot the issue.
Congratulations! You successfully published a multicontainer app to Azure Container Apps and
verified communication between containers and the use of the Azure Redis Cache within the
app.
Clean up resources
To clean up the resources you created during this tutorial, go the Azure portal and delete the
resource group that contains the container apps, cache, and container registry.
Next steps
Learn more about Azure Container Apps.
Learn about .NET Aspire, a technology that helps you more easily develop complex
containerized apps and services that integrate with diverse resources in Azure. .NET
Aspire supports development time orchestration, standardized integration with an array
of services, as well as tooling support with Visual Studio project templates.
You can also the Azure command-line interface (CLI) to work with your container apps.
Install Azure CLI and get started working with Azure Container Apps by using the Azure
CLI commands by following Deploy Azure Container Apps with the az containerapp up
command.
Prerequisites
Docker Desktop or Podman Desktop .
Visual Studio , or for Podman support, Visual Studio 2026 , with the [Link] and web
development, Azure development workload, and/or .NET desktop development
workload installed.
To publish to Azure Container Registry, an Azure subscription. Sign up for a free trial .
7 Note
Support for .NET Framework containers is discontinued in the current version of Visual
Studio. .NET Framework containers were supported up to Visual Studio 2022 17.14.
You can also specify the Container Image Distro and the Container Build Context.
Container Image Distro specifies which OS image your containers use as the base image. This
list changes if you switch between Linux and Windows as the container type.
Windows:
Windows Nano Server (recommended, only available 8.0 and later, not preset for Native
Ahead-of-time (AOT) deployment projects)
Windows Server Core (only available 8.0 and later)
Linux:
Default (Debian, but the tag matches your target .NET version)
Debian
Ubuntu
Chiseled Ubuntu
Alpine
7 Note
Containers based on the Chiseled Ubuntu image and that use Native Ahead-of-time
(AOT) deployment can only be debugged in Fast Mode. See Customize Docker
containers in Visual Studio.
Container Build Context specifies the folder that is used for docker build (or podman build ).
See Docker build context or Podman build . The default is the solution folder, which is
recommended. All the files needed for a build need to be under this folder, which is not the
case if you choose the project folder or some other folder.
a Dockerfile file
a .dockerignore file
a NuGet package reference to the [Link]
The Dockerfile you add will resemble the following code. In this example, the project was
named WebApplication-Docker , and you chose Linux containers:
Dockerfile
# See [Link] to learn how to customize your debug
container and how Visual Studio uses this Dockerfile to build your images for faster
debugging.
# This stage is used when running from VS in fast mode (Default for Debug
configuration)
FROM [Link]/dotnet/aspnet:8.0 AS base
USER $APP_UID
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
# This stage is used to publish the service project to be copied to the final stage
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./[Link]" -c
$BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
# This stage is used in production or when running from VS in regular mode (Default
when not using the Debug configuration)
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "[Link]"]
Container Image Distro specifies which OS image your containers use as the base image. This
list changes if you switch between Linux and Windows as the container. See the previous
section for a list of available images.
The .NET SDK container build entry in [Link] looks like the following code:
JSON
"Container (.NET SDK)": {
"commandName": "SdkContainer",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
"environmentVariables": {
"ASPNETCORE_HTTPS_PORTS": "8081",
"ASPNETCORE_HTTP_PORTS": "8080"
},
"publishAllPorts": true,
"useSSL": true
}
The .NET SDK manages some of the settings that would have been encoded in a Dockerfile,
such as the container base image, and the environment variables to set. The settings available
in the project file for container configuration are listed at Customizing your container . For
example, the Container Image Distro is saved in the project file as the ContainerBaseImage
property. You can change it later by editing the project file.
XML
<PropertyGroup>
<ContainerBaseImage>[Link]/dotnet/runtime:8.0-alpine-
amd64</ContainerBaseImage>
</PropertyGroup>
Next steps
For further details on the services implementation and use of Visual Studio tools for working
with containers, read the following articles:
Related content
Visual Studio Container Tools
This article illustrates how to use Visual Studio to start an app in a local container, make
changes, and then refresh the browser to see the changes. This article also shows you how to
set breakpoints for debugging for containerized apps. Supported project types include web
app, console app, and Azure function targeting .NET Core or .NET 5 and higher. The example
presented in this article are a project of type [Link] Core Web App.
If you already have a project of a supported type, Visual Studio can create a Dockerfile and
configure your project to run in a container. See Container Tools in Visual Studio.
Prerequisites
To debug apps in a local container, the following tools must be installed:
Visual Studio , or for Podman support, Visual Studio 2026 with the [Link] and web
development workload installed.
To run Docker containers locally, you must have a local Docker client. You can use Docker
Desktop , which requires Windows 10 or later.
3. Enter a name for your new application (or use the default name), specify the location on
disk, and then select Next.
4. Select the .NET version you want to target. If you're not sure, choose the LTS (long-term
support) release .
5. Choose whether you want SSL support by selecting or clearing the Configure for HTTPS
checkbox.
7. Use the Docker OS dropdown list to select the type of container you want: Windows or
Linux.
1. Make sure that Docker is set up to use the container type (Linux or Windows) that you are
using. Right-click on the Docker icon on the Taskbar, and choose Switch to Linux
containers or Switch to Windows containers as appropriate.
2. Editing your code and refreshing the running site as described in this section is not
enabled in the default templates in .NET Core and .NET 5 and later. To enable it, add the
NuGet package [Link] . Add a call to
the extension method AddRazorRuntimeCompilation to the code in the
[Link] method. You only need this enabled in DEBUG mode, so code
C#
// Add services to the container.
var mvcBuilder = [Link]();
#if DEBUG
if ([Link]())
{
[Link]();
}
#endif
For more information, see Razor file compilation in [Link] Core. The exact code might
vary, depending on the target framework and the project template you used.
3. Set Solution Configuration to Debug. Then, press Ctrl+F5 to build your Docker image
and run it locally.
When the container image is built and running in a Docker container, Visual Studio
launches the web app in your default browser.
6. Add the following HTML content to the end of the file, and then save the changes.
HTML
<h1>Hello from a Docker container!</h1>
7. In the output window, when the .NET build is finished and you see the following lines,
switch back to your browser and refresh the page:
Output
Now listening on: [Link]
Application started. Press Ctrl+C to shut down.
2. Replace the contents of the OnGet method with the following code:
C#
ViewData["Message"] = "Your application description page from within a
container";
Hot reload
Also, in Visual Studio 17.10 and later, Hot Reload is supported in containers, although be aware
that in a container, you have to refresh the page to see changes. If the change is to a CSS file,
you again have to refresh the page to see those changes. Note also that updates to scoped
CSS files ( .[Link] files, see [Link] Core Blazor CSS isolation) are not supported as part of
hot reload.
Azure Functions
If you're debugging an integrated Azure Functions project and using the token proxy in the
container to handle authentication to Azure services, you need to copy the .NET runtime onto
the container for the token proxy to run. If you're debugging an isolated Azure Functions
project, it already has the .NET runtime, so there's no need for this extra step.
To ensure the .NET runtime is available to the token proxy, add, or modify the debug layer in
the Dockerfile that copies the .NET runtime into the container image. For Linux containers, you
can add the following code to the Dockerfile:
Dockerfile
# This layer is to support debugging, VS's Token Proxy requires the runtime to be
installed in the container
FROM [Link]/dotnet/runtime:8.0 AS runtime
FROM base as debug
COPY --from=runtime /usr/share/dotnet /usr/share/dotnet
RUN ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet
Also, in the Visual Studio project, you need to make some changes to specify this as the layer
to use when debugging in Fast Mode. For an explanation of Fast Mode, see Customize Docker
containers in Visual Studio. For single container scenarios (not Docker Compose), set the
MSBuild property ContainerFastModeStage (or DockerfileFastModeStage ) to debug in order to
use that layer for debugging. For Docker Compose, modify the [Link]
as follows:
yml
# Set the stage to debug to use an image with the .NET runtime in it
services:
functionappintegrated:
build:
target: debug
For a code sample of authentication with Azure Functions, including both integrated and
isolated scenarios, see VisualStudioCredentialExample .
Container reuse
When you use Fast Mode, which Visual Studio normally uses for the Debug configuration,
Visual Studio rebuilds only your container images and the container itself when you change the
Dockerfile. If you don't change the Dockerfile, Visual Studio reuses the container from an
earlier run.
If you manually modified your container and want to restart with a clean container image, use
the Build > Clean command in Visual Studio, and then build as normal.
When you're not using Fast Mode, which is typical for the Release configuration, Visual Studio
rebuilds the container each time the project is built.
You can configure when Fast Mode is used; see How to configure Visual Studio Container Tools.
Troubleshoot
Learn how to troubleshoot Visual Studio Docker development.
Related content
Get more details by reading How Visual Studio builds containerized apps.
Prerequisites
Docker Desktop or Podman Desktop .
Visual Studio . For Podman support, Visual Studio 2026 .
For the Docker Compose node:
Docker v2, which installs with Docker Desktop and is on by default.
The left side of the window shows the list of containers on your local machine. The containers
associated with your current solution are under Solution Containers. On the right is a pane
with tabs for Environment, Labels, Ports, Volumes, Files, Logs, and Details.
If you're using Docker Compose, you see a tree of nodes, with a parent node for your solution
and child nodes for each project enrolled in Docker Compose.
Tip
By default, the Containers window is docked with the Watch window when the debugger
is running. You can easily customize where the Containers tool window is docked. See
Customizing window layouts in Visual Studio.
7 Note
Changes to the environment variables aren't reflected in real time. Also, the environment
variables in this tab are the system environment variables on the container, not the user
environment variables local to the app.
View labels
The Labels tab shows the labels for the container. Labels are a way of setting custom metadata
on Docker objects. Visual Studio sets some labels automatically.
View volumes
The Volumes tab shows the mounted filesystem nodes, or volumes, on the container.
In Visual Studio 2022 version 17.7 or later, when targeting .NET 8 or later, the Dockerfile
might contain the USER app command, which specifies to run the app with regular user
permissions. The Files tab uses the same permissions, so you might not be able to view
folders that require elevated permissions to view.
To open a file in Visual Studio, double-click the file or right-click it and choose Open. Visual
Studio opens the file in read-only mode.
View logs
The Logs tab shows the results of the docker logs command. By default, the tab shows stdout
and stderr streams on a container, but you can configure the output. For details, see Docker
logging .
By default, the Logs tab streams the logs. You can pause the stream by selecting the Stream
button on the tab. Select Stream again to resume the streaming from where it left off.
To clear the logs, use the Clear button on the Logs tab. To get all the logs, use the Refresh
button.
7 Note
Visual Studio automatically redirects stdout and stderr to the Output window when you
run Windows containers without debugging. These logs then don't display in the Logs
tab.
If you're using Docker Compose with Visual Studio 2022 version 17.7 or later, you can view logs
of each container separately or interleaved into a single output stream. If you select the parent
node for the solution, you see interleaved logs from all the Compose projects. The first column
on each line shows the container that produced that line of output. If you only want to see the
logs for one container, select that project's node.
View details
The Details tab displays metadata and runtime information about the container's configuration
in JSON format. This information includes environment variables, ports, volumes, and other
runtime settings.
Interact with containers
The confirmation dialogs for various tasks, such as removing containers and images or
launching more than 10 containers at a time, might display prompts. You can disable each
prompt by using the checkbox on the dialog window.
You can also enable or disable these options by using the settings in the Tools > Options pane
under All Settings > Container Tools > Containers Window. For more information, see
Configure Container Tools.
To select multiple containers, for example to remove more than one container at a time, use
Ctrl+Select. You're prompted to confirm if you try to start or remove more than 10 containers
at a time. You can disable the confirmation prompts if desired.
For Windows containers, the Windows command prompt opens. For Linux containers, a
window opens using the Bash shell.
If you're targeting .NET 8 in Visual Studio 2022 version 17.7 and later, your Dockerfile can
specify the USER app command, which means your app runs with regular user permissions
rather than elevated permissions. The terminal opens as the user specified in the Dockerfile,
which is app by default for .NET 8 projects. If no user is specified, the terminal runs as the root
user.
View images
You can view images on the local machine by using the Images tab on the left side of the
Containers window. Images pulled from external repositories are grouped together in a
treeview.
The right pane has the tabs applicable to images: Labels, Details, and Layers. The Details tab
shows the configuration details for the image in JSON format.
To remove an image, right-click the image in the treeview and choose Remove, or select the
image and then select the Remove button on the toolbar.
If you have the Containers tab selected, you're asked to confirm that you want to remove
all stopped containers.
If you have the Images tab selected, the prompt asks if you want to remove all dangling
images. Dangling images are images of layers that are no longer associated with a tagged
image. Prune dangling images occasionally to help conserve disk space.
Related content
Container Tools overview
Container development in Visual Studio
choosing a Docker Compose profile, which also looks at your Compose file to determine the
group of services to run.
For information about Docker Compose profiles, see Using profiles with Compose .
Prerequisites
Visual Studio
A .NET solution with Container Orchestration with Docker Compose
yml
version: '3.9'
services:
webapplication1:
image: ${DOCKER_REGISTRY-}webapplication1
profiles: [web, web1]
build:
context: .
dockerfile: WebApplication1/Dockerfile
webapplication2:
image: ${DOCKER_REGISTRY-}webapplication2
profiles: [web, web2]
build:
context: .
dockerfile: WebApplication2/Dockerfile
webapplication3:
image: ${DOCKER_REGISTRY-}webapplication3
profiles: [web]
build:
context: .
dockerfile: WebApplication3/Dockerfile
external1:
image: redis
external2:
image: redis
There are a few options to open the Docker Compose launch settings dialog:
In Visual Studio, choose Debug > Manage Docker Compose Launch Settings:
Right-click on the Visual Studio docker-compose project and select Manage Docker
Compose Launch Settings
Use the Quick Launch (Ctrl+Q) and search for Docker Compose to find the same
command.
In the example below, the web1 Compose profile is selected, which filters the Services list to
only the three out of five included in that profile:
7 Note
The Docker Compose profiles section only appears if there are profiles defined in your
[Link] files.
The next example demonstrates selecting between individual services instead of filtering to the
services in a Compose profile. Here, we show how the dialog would look if you created a new
launch profile named test2 that only starts two out of the five services, webapplication1 with
debugging and webapplication2 without debugging. This launch profile also launches a
browser when the application starts and opens it to the home page of webapplication1 .
And this information is saved in [Link] as shown below
JSON
{
"profiles": {
"test2": {
"commandName": "DockerCompose",
"composeLaunchServiceName": "webapplication1",
"serviceActions": {
"external1": "DoNotStart",
"external2": "DoNotStart",
"webapplication1": "StartDebugging",
"webapplication2": "StartWithoutDebugging",
"webapplication3": "DoNotStart"
},
"composeLaunchAction": "LaunchBrowser",
"commandVersion": "1.0",
"composeLaunchUrl": "{Scheme}://localhost:{ServicePort}"
}
}
}
To create another profile that makes use of the Compose profile, select Use Docker Compose
profiles and choose web1 . Now the launch profile includes three services: webapplication1
(which belongs to both web and web1 Compose profiles), external1 , and external2 . By
default, the services without source code such as external1 and external2 have the default
action of Start without debugging. .NET applications with source code defaults to Start
debugging.
) Important
If a service doesn't specify a Compose profile, it's included in all Compose profiles
implicitly.
This information is saved as shown in the following code. The configuration for the service and
its default action are not saved unless you change the default action.
JSON
{
"profiles": {
"test1": {
"commandName": "DockerCompose",
"composeProfile": {
"includes": [
"web1"
]
},
"commandVersion": "1.0"
}
}
}
You can also change the action of webapplication1 to Start without debugging. The settings in
[Link] then look like the following code:
JSON
{
"profiles": {
"test1": {
"commandName": "DockerCompose",
"composeProfile": {
"includes": [
"web1"
],
"serviceActions": {
"webapplication1": "StartWithoutDebugging"
}
},
"commandVersion": "1.0"
}
}
}
Properties
Here's a description of each property in the [Link]:
ノ Expand table
Property Description
composeProfile Parent property that defines the launch profile definition. Its child
properties are includes and serviceActions
composeProfile - includes List of the Compose profile names that make up a launch profile.
composeProfile - Lists the selected Compose profiles, services, and the launch action of
serviceActions each service
composeLaunchUrl The URL to use when launching the browser. Valid replacement tokens
are "{ServiceIPAddress}", "{ServicePort}", and "{Scheme}". For example:
{Scheme}://{ServiceIPAddress}:{ServicePort}
composeLaunchServiceName Specifies the service used for replacing the tokens in composeLaunchUrl.
Related content
Visual Studio Container Tools build and debug overview
Visual Studio Container Tools launch settings
Docker Compose build settings
Prerequisites
Docker Desktop or Podman Desktop .
Visual Studio , or for Podman support, Visual Studio 2026 , with the [Link] and web
development, Azure development workload, and/or .NET desktop development
workload installed.
General settings
ノ Expand table
Setting Default value Description
) Important
If you set Trust [Link] Core SSL certificate to Never and the localhost SSL certificate
isn't trusted, HTTPS web requests might fail at run time. In that case, set Trust [Link]
Core SSL certificate to Prompt me, run your project, and indicate trust at the prompt.
The following table describes Single Project and Docker Compose settings:
The following settings in the Container Warmup section control how Visual Studio optimizes
performance by starting services and preparing images ahead of anticipated use.
ノ Expand table
Pull required Enabled Whether to start a background Docker pull operation when loading a
images on container project. Required images are downloaded or downloading when
project open you're ready to run your code. If you just want to browse the code, you
can set to False to avoid downloading container images you don't need.
Setting Default Description
value
Run containers True Whether to create a container when loading a container project, so it's
on project open ready when you build and run. If you prefer to control when your container
is created, set to False.
Remove True Whether to remove containers for your solution after closing the solution
containers on or closing Visual Studio.
project close
ノ Expand table
Run a service in Enabled Whether to install and run a token proxy service in the container
containers to enable to enable Azure Authentication. This service lets your apps use
Azure Authentication Azure services during development. For more information, see the
Configure Azure authentication section.
Run a service in Enabled Whether to install and run the Hot Reload service. This service
containers to enable Hot only supports running without debugging, Ctrl+F5.
Reload
ノ Expand table
Confirm before pruning Enabled Whether to prompt you when pruning unused containers.
containers
Confirm before pruning Enabled Whether to prompt you when pruning unused images.
images
Setting Default Description
value
Confirm before removing Enabled Whether to prompt you when removing a container.
a container
Confirm before removing Enabled Whether to prompt you when removing an image.
an image
Confirm before running Enabled Whether to prompt you before starting containers from more
large number of images than 10 images at a time.
Display string format to Blank A display string format to use in the Containers window, with
use in the Containers support for {ContainerName}, {ImageName}, {ProjectName}, and
window {ContainerID} tokens.
Group containers by the Enabled Whether to group containers by the Docker Compose project
Docker Compose project they're part of.
Visual Studio deploys and runs a token proxy service in your single-container and Docker
Compose projects to help your apps and services authenticate in Azure. The feature requires
Azure Identity 1.9.0 or later.
With this service enabled, you can automatically use most Azure services within the container
without any added configuration or setup. Your code can use DefaultAzureCredential and
VisualStudioCredential to authenticate with Azure services the same way as outside of a
container. For more information, see the Azure Identity 1.9.0 README .
To disable this feature, set Run a service in containers to enable Azure Authentication to False
in the Container Tools Single Project or Docker Compose settings.
U Caution
Using the token proxy and enabling certain diagnostic logs presents a potential security
concern. These logs could expose authentication credentials as plain text. The following
environment variables enable these logs:
For single container projects, MS_VS_CONTAINERS_TOOLS_LOGGING_ENABLED , which logs in
%tmp%\[Link] .
Related content
Visual Studio Container Tools for Docker
Use the Containers window
If you don't have an Azure subscription, create a free account before you begin.
Prerequisites
Install Visual Studio , or for Podman support, Visual Studio 2026 , with the [Link]
and web development workload.
3. Enter a name for your new application (or use the default name), specify the location on
disk, and then select Next.
4. Select the .NET version you want to target. If you're not sure, choose the LTS (long-term
support) release .
5. Choose whether you want SSL support by selecting or clearing the Configure for HTTPS
checkbox.
7. Use the Docker OS dropdown list to select the type of container you want: Windows or
Linux.
2. On the Target tab, select Docker Container Registry, and then select Next.
3. On the Specific target tab, select Azure Container Registry, and then select Next.
4. On the Registry tab, select the Create new (+) option at the right:
DNS Prefix Globally unique Name that uniquely identifies your container registry.
name
Resource Your resource Name of the resource group in which to create your container
Group group registry. Select New to create a new resource group.
Visual Studio validates the property values and creates the new container resource. When
the process completes, Visual Studio returns to the Publish dialog and selects the new
container in the list.
You can now pull the container from the registry to any host capable of running Docker
images, such as Azure Container Instances.
Related content
Quickstart: Deploy a container instance in Azure using the Azure CLI
You can also deploy to Azure Container Apps. For a tutorial, see Deploy to Azure Container
Apps using Visual Studio.
If you don't have an Azure subscription, create a free account before you begin.
Prerequisites
To complete this tutorial:
Visual Studio , or for Podman support, Visual Studio 2026 , with the [Link] and web
development workload.
Install Docker Desktop or Podman Desktop .
1. From the Visual Studio start window, choose Create a new project.
2. Choose [Link] Core Web App (Razor pages), and choose Next.
3. Give your new application a name (or take the default) and choose Next.
4. Choose the .NET version you want to target.
5. Choose whether or not you want SSL support by using the Configure for HTTPS
checkbox.
6. Select the Enable container support checkbox.
7. Select the container type, and click Create.
5. You can use an existing app service or create a new one by clicking on the Create new
Azure App Service link. Find your existing app service in the treeview by expanding its
resource group, or change the View setting to Resource type to sort by type.
7 Note
In Visual Studio 2022 version 17.11 and later, the default authentication method
used for publishing to Azure changed from basic authentication to using an access
token for authentication. To use basic authentication with Visual Studio 17.11 or later,
clear the checkbox Enable secure publishing (not recommended).
6. If you create a new one, a resource group and app service will be generated in Azure. You
can change the names if desired, as long as they are unique.
7. You can accept the default hosting plan or change the hosting plan now, or later in the
Azure portal. The default is S1 (small) in one of the supported regions. To create a
hosting plan, choose New next to the Hosting Plan dropdown list. The Hosting Plan
window appears.
You can view the details about these options at Azure App Service plan overview.
8. If you chose the Azure App Service Container option, specify whether to use an existing
registry or create a new one. If you create a new one, a screen appears with settings for
the new registry. For the description of the options for SKU, see Azure Container Registry
service tiers.
9. Once you're done selecting or creating these resources, choose Finish. Your container is
deployed to Azure in the resource group and app service you selected. This process takes
a bit of time. When it's completed, the Publish tab shows information about what was
published, including the site URL.
10. The publishing profile is saved with all the details you selected, such as the resource
group and app service. If you chose Azure App Service Container, you might be asked to
enable the Admin user on the Container Registry instance.
11. Click on the site link to verify your app works as expected in Azure.
12. To deploy again with the same publishing profile, use the Publish button, the Publish
button on the Web Publish Activity window, or right-click on the project in Solution
Explorer and choose the Publish item on the context-menu.
You can view settings for your deployed App Service by opening the Container settings menu
(when you are using Visual Studio 2019 version 16.4 or later).
From there, you can view the container information, view or download logs, or set up
continuous deployment. See Azure App Service Continuous Deployment CI/CD.
Clean up resources
To remove all Azure resources associated with this tutorial, delete the resource group using the
Azure portal . To find the resource group associated with a published web application, choose
View > Other Windows > Web Publish Activity, and then choose the gear icon. The Publish
tab opens, which contains the resource group.
In the Azure portal, choose Resource groups, select the resource group to open its details
page. Verify that this is the correct resource group, then choose Remove resource group, type
the name, and choose Delete.
Related content
Azure App Service
Deploy to Azure Container Registry
Prerequisites
Docker Desktop .
Visual Studio with the [Link] and web development, Azure development workload,
and/or .NET desktop development workload installed.
If you don't have a Docker Hub repository, create one at Docker Hub .
Visual Studio attempts to deploy your image to the Docker Hub. If successful, the Publish
screen appears with the URL for the repository image, the image tag, repository, and the
build configuration (for example, Release).
5. You can update the image at any time by clicking on the Publish button on this page. Or,
you can modify or remove the profile, by using the links underneath the URL.
Next steps
Publish to Azure Container Registry by following the steps at Deploy to Azure Container
Registry.
Related content
Deploy to Azure App Service
Visual Studio Container Tools.
Prerequisites
Install Visual Studio .
A .NET 7 or later project
For Azure targets, an Azure subscription. Sign up for a free trial .
For Docker Hub, a Docker account. If you don't have one, you can sign up .
If you create a new one, review and modify the default app name, resource group,
location, environment, and container name, and choose Create. It might take some time
to create the resources in Azure.
4. Choose Finish and wait for the container app to be created. If you see a message box
about enabling the Admin user on the container instance, you'll need to accept this to
continue.
When the container app has been created, Visual Studio creates a publish profile ( .pubxml file)
and displays the settings on the Publish tab.
You can access the containerized web site online using the Site link.
Next time you want to publish using the same target and settings, you can use the Publish
button on this screen. If you want to publish using different settings, use the New button. You
can repeat the entire process and save the target and other settings in a separate .pubxml file.
Clean up resources
To clean up resources, use the Azure portal or use the Azure CLI or Azure PowerShell to delete
the resource group, if you created one, or delete the resources individually.
Related content
Learn more about:
Suppose you want to make a change in the Dockerfile and see the results in both debugging
and in production containers. In that case, you can add commands in the Dockerfile to modify
the first stage (usually base ). See Modify the container image for debugging and production.
But, if you want to make a change only when debugging, but not production, then you should
create another stage, and use the ContainerFastModeStage build setting to tell Visual Studio to
use that stage for debug builds. See Modify the container image only for debugging.
This article explains the Visual Studio build process for containerized apps in some detail, then
it contains information on how to modify the Dockerfile to affect both debugging and
production builds, or just for debugging.
Prerequisites
Docker Desktop or Podman Desktop .
Visual Studio , or for Podman support, Visual Studio 2026 , with the [Link] and web
development, Azure development workload, and/or .NET desktop development
workload installed.
7 Note
This section describes the container build process that Visual Studio uses when you
choose the Dockerfile container build type. If you're using the .NET SDK build type, the
customization options are different, and the information in this section isn't applicable.
Instead, see Containerize a .NET app with dotnet publish and use the properties
described at Customize your container to configure the container build process.
Multistage build
When Visual Studio builds a project that doesn't use Docker containers, it invokes MSBuild on
the local machine and generates the output files in a folder (typically bin ) under your local
solution folder. For a containerized project, however, the build process takes account of the
Dockerfile's instructions for building the containerized app. The Dockerfile that Visual Studio
uses is divided into multiple stages. This process relies on Docker's multistage build feature.
The multistage build feature helps make the process of building containers more efficient, and
makes containers smaller by allowing them to contain only the bits that your app needs at run
time.
The multistage build allows container images to be created in stages that produce
intermediate images. As an example, consider a typical Dockerfile. The first stage is called base
in the Dockerfile that Visual Studio generates, although the tools don't require that name.
Dockerfile
# This stage is used when running from VS in fast mode (Default for Debug
configuration)
FROM [Link]/dotnet/aspnet:8.0 AS base
USER $APP_UID
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
The lines in the Dockerfile begin with the [Link] image from Microsoft Container Registry
([Link]) and create an intermediate image base that exposes ports 8080 and 8081,
and sets the working directory to /app .
When you're targeting .NET 7 and later, the USER $APP_UID line appears, which sets the
container to run without elevated privileges with a username obtained from the environment
variable APP_UID . The ports are 8080 and 8081, rather than 80 and 443, which require elevated
privileges.
Dockerfile
Dockerfile
# This stage is used to publish the service project to be copied to the final stage
FROM build AS publish
RUN dotnet publish "[Link]" -c Release -o /app/publish
# This stage is used in production or when running from VS in regular mode (Default
when not using the Debug configuration)
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "[Link]"]
The final stage starts again from base , and includes the COPY --from=publish to copy the
published output to the final image. This process makes it possible for the final image to be a
lot smaller, since it doesn't need to include all of the build tools that were in the sdk image.
The following table summarizes the stages used in the typical Dockerfile created by Visual
Studio:
ノ Expand table
Stage Description
base Creates the base runtime image where the built app is published. Settings that need to be
available at runtime go here, such as ports and environment variables. This stage is used
when running from VS in fast mode (Default for Debug configuration).
build The project is built in this stage. The .NET SDK base image is used, which has the components
required to build your project.
publish This stage derives from the build stage and publishes your project, which will be copied to
the final stage.
final This stage configures how to start the app and is used in production or when running from
VS in regular mode (Default when not using the Debug configuration).
aotdebug This stage is used as the base for the final stage when launching from VS to support
debugging in regular mode (Default when not using the Debug configuration).
7 Note
The aotdebug stage is only supported for Linux containers. It's used in Visual Studio 2022
17.11 and later if native Ahead Of Time (AOT) deployment is enabled on the project.
Project warmup
Project warmup refers to a series of steps that happen when the Container profile is selected
for a project (that is, when a project is loaded or container support is added) in order to
improve the performance of subsequent runs (F5 or Ctrl+F5).
This behavior is configurable in the Tools > Options pane under All Settings > Container
Tools. Here are the tasks that run in the background:
Check that the container runtime (Docker Desktop or Podman) is installed and running.
Ensure that Docker Desktop is set to the same operating system as the project. (This
check isn't applicable to Podman, which only supports Linux containers.)
Pull the images in the first stage of the Dockerfile (the base stage in most Dockerfiles).
Build the Dockerfile and start the container.
Warmup only happens in Fast mode, so the running container has the app folder volume-
mounted. That means that any changes to the app don't invalidate the container. This behavior
improves the debugging performance significantly and decreases the wait time for long
running tasks such as pulling large images.
2 Warning
When logging is enabled and you're using a token proxy for Azure authentication,
authentication credentials could be logged as plain text. See Configure Azure
authentication.
Next steps
Learn about how to use the Dockerfile stages to customize the images used for debugging and
production, for example, how to install a tool on the image only when debugging. See
Configure container images for debugging.
Related content
MSBuild properties for container projects.
Dockerfile on Windows
Linux containers on Windows
Prerequisites
Docker Desktop or Podman Desktop .
Visual Studio , or for Podman support, Visual Studio 2026 , with the [Link] and web
development, Azure development workload, and/or .NET desktop development
workload installed.
In Fast mode, Visual Studio calls docker build or podman build with an argument that tells the
container runtime to build only the first stage in the Dockerfile (normally the base stage). You
can change that by setting the MSBuild property, ContainerFastModeStage , which replaces the
obsolete DockerfileFastModeStage . See Container Tools MSBuild properties. Visual Studio
handles the rest of the process without regard to the contents of the Dockerfile. So, when you
modify your Dockerfile, such as to customize the container environment or install additional
dependencies, you should put your modifications in the first stage. Any custom steps placed in
the Dockerfile's build , publish , or final stages aren't executed.
This performance optimization normally only occurs when you build in the Debug
configuration. In the Release configuration, the build occurs in the container as specified in the
Dockerfile. You can enable this behavior for the Release configuration by setting
ContainerDevelopmentMode to Fast in the project file:
XML
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<ContainerDevelopmentMode>Fast</ContainerDevelopmentMode>
</PropertyGroup>
If you want to disable the performance optimization for all configurations, and build as the
Dockerfile specifies, then set the ContainerDevelopmentMode property to Regular in the
project file as follows:
XML
<PropertyGroup>
<ContainerDevelopmentMode>Regular</ContainerDevelopmentMode>
</PropertyGroup>
To restore the performance optimization, remove the property from the project file.
When you start debugging (F5), a previously started container is reused, if possible. If you don't
want to reuse the previous container, you can use Rebuild or Clean commands in Visual Studio
to force Visual Studio to use a fresh container.
The process of running the debugger depends on the type of project and container operating
system:
ノ Expand table
.NET Core apps (Linux Visual Studio downloads vsdbg and maps it to the container, then it gets
containers) called with your program and arguments (that is, dotnet [Link] ).
.NET Core apps Visual Studio uses onecoremsvsmon and maps it to the container, runs it as the
(Windows containers) entry point.
For information on [Link] , see Offroad debugging of .NET Core on Linux and OS X from
Visual Studio .
customization that flows to the final stage and the ContainerFastModeStage , if possible.
See Container Tools build properties.
Dockerfile
# This stage is used when running from VS in fast mode (Default for Debug
configuration)
FROM [Link]/dotnet/aspnet:8.0 AS base
USER $APP_UID
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
# <add your commands here>
# This stage is used to publish the service project to be copied to the final stage
FROM build AS publish
RUN dotnet publish "[Link]" -c Release -o /app/publish
# This stage is used in production or when running from VS in regular mode (Default
when not using the Debug configuration)
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "[Link]"]
To modify the container only for debugging, create a stage and then use the MSBuild property
ContainerFastModeStage to tell Visual Studio to use your customized stage when debugging.
Refer to the Dockerfile reference in the Docker documentation for information about
Dockerfile commands.
7 Note
The instructions here apply to the single-container case. You can also do the same thing
for multiple containers with Docker Compose, but the techniques required for Docker
Compose are slightly different. For example, the stage is controlled by a setting in the
[Link] file.
In the following example, we install the package procps-ng , but only in debug mode. This
package supplies the command pidof , which Visual Studio requires (when targeting .NET 5
and earlier) but isn't in the Mariner image used here. The stage we use for fast mode
debugging is debug , a custom stage defined here. The fast mode stage doesn't need to inherit
from the build or publish stage, it can inherit directly from the base stage, because Visual
Studio mounts a volume that contains everything needed to run the app, as described earlier in
this article.
Dockerfile
#See [Link] to understand how Visual Studio uses this
Dockerfile to build your images for faster debugging.
# This stage is used when running from VS in fast mode (Default for Debug
configuration)
FROM [Link]/dotnet/aspnet:8.0 AS base
USER $APP_UID
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
# This stage is used to publish the service project to be copied to the final stage
FROM build AS publish
RUN dotnet publish "[Link]" -c Release -o /app/publish
# This stage is used in production or when running from VS in regular mode (Default
when not using the Debug configuration)
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "[Link]"]
In the project file, add this setting to tell Visual Studio to use your custom stage debug when
debugging.
XML
<PropertyGroup>
<!-- other property settings -->
<ContainerFastModeStage>debug</ContainerFastModeStage>
</PropertyGroup>
Dockerfile
# These ARGs allow for swapping out the base used to make the final image when
debugging from VS
ARG LAUNCHING_FROM_VS
# This sets the base image for final, but only if LAUNCHING_FROM_VS has been defined
ARG FINAL_BASE_IMAGE=${LAUNCHING_FROM_VS:+aotdebug}
# This stage is used as the base for the final stage when launching from VS to
support debugging in regular mode (Default when not using the Debug configuration)
FROM base as aotdebug
USER root
# Install GDB to support native debugging
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
gdb
USER app
# This stage is used in production or when running from VS in regular mode (Default
when not using the Debug configuration)
FROM ${FINAL_BASE_IMAGE:-[Link]/dotnet/runtime-deps:8.0} AS final
WORKDIR /app
EXPOSE 8080
COPY --from=publish /app/publish .
ENTRYPOINT ["./WebApplication1"]
You can use aotstage in the Dockerfile to customize the image used at debug time, without
affecting the final image used when not launching from Visual Studio, or in production. For
example, you could install a tool for use only during debugging.
Related content
Customize Docker containers in Visual Studio
Build a container project from the command line
Prerequisites
Docker Desktop or Podman Desktop .
Visual Studio , or for Podman support, Visual Studio 2026 with the [Link] and web
development, Azure development workload, and/or .NET desktop development
workload installed.
ノ Expand table
Volume Description
App folder Contains the project folder where the Dockerfile is located.
NuGet Contains the NuGet packages and fallback folders that are read from the
packages obj{project}.[Link] file in the project.
folders
Remote Contains the bits required to run the debugger in the container depending on the
debugger project type. For more information, see Customize container images for debugging.
Source folder Contains the build context that is passed to Docker commands.
VSTools Contains Visual Studio tools that support working with the container, including support
for the debugger, the Containers window, handling Azure tokens, the Hot Reload agent,
and the Distroless Helper.
For .NET 8 and later, additional mount points at root and for the app user that contain user
secrets and the HTTPS certificate might also be present.
7 Note
If you're using Docker Engine in Windows Subsystem for Linux (WSL) without Docker
Desktop, set the environment variable VSCT_WslDaemon=1 to have Visual Studio use WSL
paths when creating volume mounts. The NuGet package
[Link] 1.20.0-Preview 1 is also
required.
For [Link] core web apps, there might be two additional folders for the SSL certificate and
the user secrets, which is explained in more detail at Use SSL for containerized [Link] Core
apps
JSON
Refer to the container runtime provider's documentation for the command-line syntax for
the Docker -v or --mount options, or the Podman -v option and the Podman --
mount option .
Related content
Customize containers in Visual Studio
Dockerfile on Windows
Linux containers on Windows
command line.
If you're using the .NET SDK build type, you don't have a Dockerfile, so you can't use docker
build or podman build ; instead, use dotnet publish /t:PublishContainer to build on the
command line.
Prerequisites
Docker Desktop or Podman Desktop .
Visual Studio , or for Podman support, Visual Studio 2026 , with the [Link] and web
development, Azure development workload, and/or .NET desktop development
workload installed.
provide the build context argument. The build context for a Dockerfile is the folder on the local
machine that's used as the working folder to generate the image. For example, it's the folder
that you copy files from when you copy to the container. In .NET Core projects, the default is to
use the folder that contains the solution file (.sln or .slnx). Expressed as a relative path, this
argument is typically ".." for a Dockerfile in a project folder, and the solution file in its parent
folder.
You can set the build context in the project file by setting the ContainerBuildContext property.
For example,
XML
<PropertyGroup>
<ContainerBuildContext>contextfolder</ContainerBuildContext>
</PropertyGroup>
Relative paths in the Dockerfile are relative to the build context, so if you change the context,
be sure to update the relative paths accordingly.
When you add container support to a project, you can specify a folder for the build context. If
you want to change the build context, you could delete the Dockerfile (if it doesn't have other
changes you want to keep), and rerun Add Container Support, this time specifying the new
build context. The new Dockerfile will have relative paths updated to correspond to the new
build context.
Use MSBuild
7 Note
This section describes how you can customize your containers when you choose the
Dockerfile container build type. If you are using the .NET SDK build type, the
customization options are different, and the information in this article isn't applicable.
Instead, see Containerize a .NET app with dotnet publish.
To build an image for single Docker container project, you can use MSBuild with the
/t:ContainerBuild command option. This command tells MSBuild to build the target
You see output similar to what you see in the Output window when you build your solution
from the Visual Studio IDE. Always use /p:Configuration=Release , since in cases where Visual
Studio uses the multistage build optimization, results when building the Debug configuration
might not be as expected. See Customize container images for debugging.
If you're using a Docker Compose project, use this command to build images:
image without nonstandard optimizations, you can right-click on the Dockerfile and choose the
Build Image option.
Visual Studio uses the dev tag to designate images that it has specially prepared to optimize
the startup time during debugging. However, these images shouldn't be used outside of the
context of Visual Studio. This tag is an indication the images have nonstandard modifications
and customizations, for example, to support Fast Mode debugging. See Customize Docker
containers in Visual Studio.
Related content
MSBuild properties for container projects.
MSBuild
Prerequisites
Docker Desktop or Podman Desktop .
Visual Studio , or for Podman support, Visual Studio 2026 , with the [Link] and web
development, Azure development workload, and/or .NET desktop development
workload installed.
ノ Expand table
Linux For .NET 6 and later, the entry point is dotnet --roll-forward Major
containers /VSTools/DistrolessHelper/[Link] --wait . For .NET 5 and earlier, the entry
point is tail -f /dev/null . These processes use an infinite wait to keep the container
running when the app is not running. When the app is launched, with or without
debugging, it's the debugger that is responsible to run the app (that is, dotnet [Link] ).
DistrolessHelper monitors the app process, and exits with the app's exit code when the
app process ends.
The container entry point can only be modified in Docker Compose projects, not in single-
container projects. See Docker Compose properties - Customize the app startup process.
Related content
MSBuild properties for container projects.
MSBuild
Dockerfile on Windows
Linux containers on Windows
Last updated on 09/18/2025
Use SSL for containerized [Link] Core
apps
SSL (Secure Sockets Layer) provides secure connections over HTTP (HTTPS). This method of
securing connections uses a certificate, and in a containerized app, the port mappings are
different for secured and unsecured entry points.
Prerequisites
Docker Desktop or Podman Desktop .
Visual Studio , or for Podman support, Visual Studio 2026 , with the [Link] and web
development, Azure development workload, and/or .NET desktop development
workload installed.
Certificates
Container tools in Visual Studio support debugging an SSL-enabled [Link] core app with a
dev certificate, the same way you'd expect it to work without containers. To make that happen,
Visual Studio adds a couple of more steps to export the certificate and make it available to the
container. Here is the flow that Visual Studio handles for you when debugging in the container:
1. Ensures the local development certificate is present and trusted on the host machine
through the dev-certs tool.
*%APPDATA%\Microsoft\UserSecrets
*%APPDATA%\[Link]\Https
[Link] Core looks for a certificate that matches the assembly name under the Https folder,
which is why it's mapped to the container in that path. The certificate path and password can
alternatively be defined using environment variables (that is,
ASPNETCORE_Kestrel__Certificates__Default__Path and
ASPNETCORE_Kestrel__Certificates__Default__Password ) or in the user secrets json file, for
example:
JSON
{
"Kestrel": {
"Certificates": {
"Default": {
"Path": "c:\\app\\[Link]",
"Password": "strongpassword"
}
}
}
}
If your configuration supports both containerized and non-containerized builds, you should
use the environment variables, because the paths are specific to the container environment.
For more information about using SSL with [Link] Core apps in containers, see Hosting
[Link] Core images with Docker over HTTPS.
For a code sample that demonstrates creating custom certificates for a multi-service app that
are trusted on the host and in the containers for HTTPS service-to-service communication, see
CertExample .
If you plan to deploy your containerized app to Azure, see Configure HTTPS when deploying
containerized applications to Azure.
Last updated on 09/18/2025
Configure HTTPS when deploying
containerized applications to Azure
When you deploy a containerized application, you typically use the HTTPS protocol for
encrypted, secure communication. The secure communication is implemented by Transport
Layer Security (TLS), which replaces the earlier method using Secure Sockets Layer (SSL).
Prerequisites
Docker Desktop or Podman Desktop .
Visual Studio , or for Podman support, Visual Studio 2026 , with the [Link] and web
development, Azure development workload, and/or .NET desktop development
workload installed.
Devtest certificates
During development, Visual Studio uses a self-signed certificate, sometimes called a devtest
certificate. You get a prompt asking you to trust the certificate when you launch the application
on your local machine for the first time. This is acceptable for development and testing, but
when you deploy to Azure and expose your application on a custom domain, you need to
switch to a certificate issued by a Certificate Authority (CA), either Azure or a third-party CA.
In general, Azure services can support multiple ways of obtaining and storing certificates. You
may obtain trusted certificates from Azure's own certificate authority (CA), or you may upload
private trusted certificates issued by a third-party CA. You may make use of the service's own
certificate store, or you may use Azure Key Vault to store the certificate, along with other
secrets.
The following table shows the services and includes links that explain how HTTPS security
works when you deploy to these services and how-to guides for managing the certificates.
ノ Expand table
Azure Notes
Service
Azure App Azure App Service is a suitable deployment service for a single container that provides a
Service default experience that means you get a secure endpoint with a trusted certificate
provided by Azure without any additional overhead. For greater control, you can choose
from multiple options for obtaining and storing the certificate. You may use your own
trusted certificate obtained from a third-party CA instead of the default trusted certificate
provided by Azure. Optionally, you can store certificates in Azure Key Vault. See App
Service TLS overview.
Azure Azure Container Apps is a suitable hosting service for containerized apps using one or
Container more containers. Like Azure App Service, it provides a default experience that uses
Apps trusted Azure-provided certificates automatically, but also provides a range of
networking architecture options to support different scenarios. See Networking in Azure
Container Apps.
Azure To configure HTTPS public endpoint for a container hosted in Azure Container Instances,
Container see Enable a TLS endpoint in a sidecar container. This option minimizes the impact to the
Instances container itself.
Azure See the guidance in the AKS documentation for setting up TLS for an ingress to your
Kubernetes cluster. AKS provides the most advanced management capabilities, handling rotation and
Service (AKS) renewal of certificates with maximum flexibility.
For Azure Container Apps, you can configure ingress which uses HTTPS for external callers, and
within the network of multiple containers, use HTTP or TCP. For secure communication
between containers, you can use mTLS (mutual TLS), which requires certificates on both sides
of a request, client and server, or between microservices. See Ingress in Azure Container Apps
and Configure client certificate authentication in Azure Container Apps.
Related content
Deploy an [Link] Core container to Azure App Service using Visual Studio
Use SSL for containerized [Link] Core apps
Last updated on 11/18/2025
Troubleshoot Visual Studio
development with Docker
Article • 02/20/2025
When you're working with Visual Studio Container Tools, you may encounter issues
while building or debugging your application. This article introduces some common
troubleshooting steps for the issues.
1. Right-click Docker for Windows in the notification area, and then select Settings.
2. Select Resources > File Sharing and share the folder that needs to be accessed.
Sharing your entire system drive is possible but not recommended.
Tip
Visual Studio prompts you when Shared Drives aren't configured.
del %userprofile%\vsdbg
del %userprofile%\onecoremsvsmon
Mounts denied
When using Docker for macOS, you might encounter an error referencing the folder
/usr/local/share/dotnet/sdk/NuGetFallbackFolder. Add the folder to the File Sharing tab
in Docker.
You must be a member of the 'docker-users' group in order to have permissions to work
with Docker containers. To add yourself to the group in Windows 10 or later, follow
these steps:
You can also use the net localgroup command at the Administrator command prompt
to add users to specific groups.
1. Right-click on the Docker icon on the task bar and select Settings.
3. In the editing pane, add the graph property setting with the value of your desired
location for Docker images:
JSON
"graph": "D:\\mypath\\images"
4. Select Apply & Restart. These steps modify the configuration file at
%ProgramData%\docker\config\[Link]. Previously built images aren't moved.
To resolve this issue, right-click the Docker for Windows icon in the System Tray and
select Switch to Windows containers... or Switch to Linux containers....
Other issues
For any other issues you encounter, see Microsoft/DockerTools issues.
References
Container Tools error messages
Feedback
Was this page helpful? Yes No
To set the value of a property, edit the project file. For example, suppose your Dockerfile is named MyDockerfile. You can set the
DockerfilePath property in the project file as follows.
XML
<PropertyGroup>
<DockerfilePath>MyDockerfile</DockerfilePath>
</PropertyGroup>
7 Note
The property DockerfilePath replaces the deprecated property DockerfileFile , which is still supported in the current
version of Visual Studio.
You can add the property setting to an existing PropertyGroup element, or if there isn't one, create a new PropertyGroup element.
There is just one property, EnableSdkContainerDebugging , in the project file that is needed for .NET SDK containerized projects. It
must be set to True for .NET SDK projects to enable debugging.
XML
<PropertyGroup>
<EnableSdkContainerDebugging>True</EnableSdkContainerDebugging>
</PropertyGroup>
The following table shows the MSBuild properties available for Dockerfile projects. The NuGet package version applies to
[Link] .
Some of the properties and item lists in the following table are equivalent replacements for obsolete properties. In that case, the
obsolete property that it replaces is also named. We recommend updating projects to use the currently supported properties.
Support for obsolete properties might be removed in a future update of Visual Studio.
Some properties listed as obsolete are replaced by equivalent values in [Link], and one is replaced by MSBuild item
list.
ノ Expand table
Mode" debugging) is
enabled. Allowed values are
Fast and Regular.
ContainerFastModeProjectMountDirectory In Fast Mode, this property C:\app (Windows) or /app 1.23.0 for
controls where the project (Linux) ContainerFastModeProjectMountDirectory
(replaces output directory is volume-
DockerFastModeProjectMountDirectory ) mounted into the running 1.9.2 for
container. DockerFastModeProjectMountDirectory
ContainerBuildContext The default context used Set by Visual Studio when 1.23.0 for ContainerBuildContext
when building the Docker Docker support is added to a
(replaces DockerfileContext ) image, as a path relative to project. It's set to the relative 1.0.1872750 for DockerfileContext
the Dockerfile. path to the solution folder
(usually "..").
ContainerFastModeStage The Dockerfile stage (that is, First stage found in the -
target) to be used when Dockerfile (usually base)
(replaces DockerfileFastModeStage ) building the image in debug
mode.
ContainerRepository The repository to use in the The assembly name. 1.23.0 for ContainerRepository
label, for example
(replaces DockerRepository ) webapplication1 in the label
webapplication1:dev .
ContainerImageTag or The tag to use when Assembly name after 1.23.0 for ContainerImageTag ,
ContainerImageTags building the image. In stripping nonalphanumeric ContainerImageTags
debugging, a ":dev" is characters with the following
(replaces DockerfileTag ) appended to the tag. rules: 1.0.1872750 for DockerfileTag .
If the resultant tag is all
numeric, then "image" is
Property name Description Default value Minimum NuGet package version
ContainerRepository and ContainerImageTag (or ContainerImageTags ) provide the ability to specify the two parts of an image
label, the repository and one or more tags (for example, webapp1:alpha ). In previous versions of Visual Studio, you could use the
DockerfileTag property to specify the repository and a single tag, but this had limitations, for example, there was no ability to
specify multiple tags. The property DockerfileTag is obsolete; projects should now use ContainerRepository and
ContainerImageTag , and the current version also supports ContainerImageTags for multiple tags.
In previous Visual Studio versions, the syntax was <DockerfileTag>webapp1:alpha</DockerfileTag> . The current equivalent is
<ContainerRepository>webapp1</ContainerRespository> and <ContainerImageTag>alpha</ContainerImageTag> , or
Example
The following project file shows examples of some of these settings.
XML
<Project Sdk="[Link]">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>8c7ab9a5-d578-4c40-8b6d-54d174002229</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<!-- By default, Visual Studio uses the folder above the Dockerfile.
The path is relative to the Dockerfile, so here the context is
set to the same folder as the Dockerfile. -->
<ContainerBuildContext>.</ContainerBuildContext>
<!-- Set `docker run` arguments to mount a volume -->
<DockerfileRunArguments>-v $(MSBuildProjectDirectory)/host-folder:/container-folder:ro</DockerfileRunArguments>
<!-- Set `docker build` arguments to add a custom tag -->
<ContainerBuildArguments>-t contoso/front-end:v2.0</ContainerBuildArguments>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="[Link]" Version="1.20.1" />
</ItemGroup>
</Project>
7 Note
The build context, which you can set by providing a value for ContainerBuildContext (or DockerfileContext ), is usually
different in Visual Studio for projects from what docker build (or podman build ) uses when you run it from the command
line. The departure from the behavior of the build command line is necessary to ensure that build artifacts at the solution
level can be included.
When you call docker build (or podman build ), you always specify a build context, and you can optionally specify a path to
the Dockerfile. The default is that the Dockerfile is in the root of the context, but you can use the -f flag to specify an
alternate location. For example, you can build with docker build -f Dockerfile .. from the project directory, or docker
build -f ProjectName/Dockerfile . from the solution directory.
Next steps
For information on MSBuild properties generally, see MSBuild Properties.
See also
Docker Compose build properties
XML
<PropertyGroup>
<DockerLaunchAction>LaunchBrowser</DockerLaunchAction>
</PropertyGroup>
You can add the property setting to an existing PropertyGroup element, or if there isn't one,
create a new PropertyGroup element.
ノ Expand table
DependencyAwareStart Enables a different way of launching the app that supports the Docker
Compose properties depends_on and healthcheck , which control
service startup order and health checks.
DockerComposeBaseFilePath Specifies the first part of the filenames of the Docker Compose files,
without the .yml extension. For example:
1. DockerComposeBaseFilePath = null/undefined: use the base file
path docker-compose , and files will be named [Link] and
[Link].
2. DockerComposeBaseFilePath = mydockercompose: files will be
named [Link] and [Link].
3. DockerComposeBaseFilePath = ..\mydockercompose: files will be up
one level.
DockerComposeEnvFilePath The relative path to an .env file that's passed to docker compose
commands via --env-file . See Use the env_file attribute .
DockerDevelopmentMode Controls whether the user project is built in the container. The
allowed values of Fast or Regular control which stages are built in a
Dockerfile. The Debug configuration is Fast mode by default and
Regular mode otherwise.
DockerServiceUrl The URL to use when launching the browser. Valid replacement
tokens are "{ServiceIPAddress}", "{ServicePort}", and "{Scheme}". For
example: {Scheme}://{ServiceIPAddress}:{ServicePort}
Example
If you change the location of the docker-compose files, by setting DockerComposeBaseFilePath to
a relative path, then you also need to make sure that the build context is changed so that it
references the solution folder. For example, if your docker-compose file is a folder called
DockerComposeFiles, then Docker Compose file should set the build context to ".." or "../..",
depending on where it is relative to the solution folder.
XML
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" Sdk="[Link]">
<PropertyGroup Label="Globals">
<ProjectVersion>2.1</ProjectVersion>
<DockerTargetOS>Windows</DockerTargetOS>
<ProjectGuid>154022c1-8014-4e9d-bd78-6ff46670ffa4</ProjectGuid>
<DockerLaunchAction>LaunchBrowser</DockerLaunchAction>
<DockerServiceUrl>{Scheme}://{ServiceIPAddress}{ServicePort}</DockerServiceUrl>
<DockerServiceName>webapplication1</DockerServiceName>
<DockerComposeBaseFilePath>DockerComposeFiles\mydockercompose</DockerComposeBaseFile
Path>
<AdditionalComposeFilePaths>AdditionalComposeFiles\[Link]</Addition
alComposeFilePaths>
</PropertyGroup>
<ItemGroup>
<None Include="DockerComposeFiles\[Link]">
<DependentUpon>DockerComposeFiles\[Link]</DependentUpon>
</None>
<None Include="DockerComposeFiles\[Link]" />
<None Include=".dockerignore" />
</ItemGroup>
</Project>
The [Link] file should look like this, with the build context set to the relative
path of the solution folder (in this case, .. ).
yml
version: '3.4'
services:
webapplication1:
image: ${DOCKER_REGISTRY-}webapplication1
build:
context: ..
dockerfile: WebApplication1\Dockerfile
7 Note
To find out the default values for any of the Visual Studio settings, look in the intermediate
output directory (for example, obj/Docker) for [Link] or docker-
[Link]. These files are generated by Visual Studio and should not be
modified.
yml
services:
webapplication1:
labels:
[Link]: "C:\\my_app_folder"
Use double quotes around the values, as in the preceding example, and use the backslash as
an escape character for backslashes in paths.
ノ Expand table
[Link]
yml
services:
webapplication1:
build:
target: customStage
labels:
...
Next steps
For information on MSBuild properties generally, see MSBuild Properties.
See also
Container Tools build properties
You can edit this file directly, but in Visual Studio IDE, you can also edit the properties in this
file through the UI. Choose the dropdown list next to the launch option (for example, Docker
or .NET SDK ), and then choose Debug Properties for a single-container project.
For Docker Compose, choose Manage Docker Compose Launch Settings, and see Launch a
subset of compose services.
In [Link], the settings in the Docker section are related to how Visual Studio
handles containerized apps.
JSON
"Docker (Dockerfile)": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
"environmentVariables": {
"ASPNETCORE_HTTPS_PORTS": "8081",
"ASPNETCORE_HTTP_PORTS": "8080"
},
"publishAllPorts": true,
"useSSL": true
}
You can also use "Container (Dockerfile)" , which is more accurate if you want to use Podman,
although "Docker (Dockerfile)" works for both Docker and Podman container runtimes.
The commandName setting identifies that this section applies to Container Tools.
Most of the settings in [Link] are available and applicable whether you're using
a Dockerfile, or using the .NET SDK's built-in container build support (available for .NET 7 and
later).
The following table shows the properties that can be set in this section:
ノ Expand table
- {ProjectDir} - Full
Property in Setting name in Example Description
Debug [Link]
Profile UI
- {Scheme} - Replaced
with either http or
https , depending on
whether SSL is used.
- {ServiceHost} -
Usually replaced with
localhost .
When you're targeting
Windows containers on
Windows 10 RS3 or
older, though, it's
replaced with the
container's IP.
- {ServicePort} -
Usually replaced with
either sslPort or
httpPort, depending on
whether SSL is used.
When you're targeting
Property in Setting name in Example Description
Debug [Link]
Profile UI
Windows containers on
Windows 10 RS3 or
older, though, it's
replaced with the HTTP
or HTTPS port
specified by the
environment variables
ASPNETCORE_URLS and
ASPNETCORE_HTTP_PORTS ,
or 80 for HTTP and 443
for HTTPS if not set.
Not all settings are available in the UI, for example, useSSL . To change those settings, edit
[Link] directly.
The containerRunArguments can be set in the Launch Profiles UI as Container run arguments . It
is equivalent to the obsolete MSBuild property DockerfileRunArguments .
7 Note
If the same setting is found in both the project file and in the launch settings file, the value
in the launch settings file takes precedence.
Next steps
Configure your project by setting the Container Tools build properties.
See also
Docker Compose build properties
Manage launch profiles for Docker Compose
CTC1001 Docker volume sharing is not This error happens when Enable Docker file sharing.
enabled file sharing is not
enabled. File sharing
allows local directories on
Windows to be shared
with Linux containers.
This is applicable only in
Linux containers that are
using Hyper-V mode. See
Docker Desktop for
Windows user manual or
Docker Documentation
for more details.
CTC1007 Downloading vsdbg failed but This is just a warning and No action needed from user.
an existing copy was found on the debugging will not
disk fail. This warning happens
when the latest version of
vsdbg fails to download
Code Description Notes Fix
CTC1008 Downloading vsdbg failed and F5 failed to download Check your Internet
no existing copy was found on [Link] . connection.
disk
CTC1010 The current user is not in the The current user is not in the
docker-users group docker-users group. Add
yourself to the docker-users
group and then log out and
back in to Windows.
CTC1011 Ports are in use A container is trying to Stop the previous container or
use a specific host port other application that uses this
that is already in use. port or update the application
to use different port.
CTC1019 Unused
CTC1020 UnauthorizedAccessException
thrown while trying to start the
container
CTC1022 Unused
Code Description Notes Fix
CTC1025 An error occurred while trying See the Output window for a
to pull a Docker image. more detailed error on why the
docker pull command failed.
CTC1026 Launch setting parsing error. Unable to find the Make sure the IISExpress
IISExpress settings or settings in [Link] is
parsing failure while valid.
parsing the IISExpress
setting in the
[Link] file.
CTC1027 Error running the dev-certs An error occurred while See the Output window for
tool. running the dev-certs more detailed error.
tool to trust the [Link]
Core development
certificate.
CTC1028 Invalid Launch URL The application URL that Ensure the launchUrl specified
will be launched when in the Docker launch settings in
the debugging starts is [Link]
invalid
CTC1029 Docker execution failed An error occurred while See the Output window for
trying to run a command more detailed error.
to start the application
process inside the
container.
CTC1032 Unused
CTC1033 Unused
CTC1034 Unused
Code Description Notes Fix
CTC1037 Blazor Manifest file access error Rewriting Blazor static See the Output window for
web assets file failed more detailed error.
when debugging the
Blazor application.
CTC1038 The container is absent or not See the Output window for
running at the time of more detail on why the
debugging container failed to start.
DTP1001 Host port not found In the Docker Compose project, the Ensure the container is started
Service URL specifies the token with a host port for the right
{ServicePort} , but the container URL scheme ( http or https ).
Code Description Notes Fix
DTP1002 Container not When debugging the Docker See the Output window for
found Compose project, the container was more detail on why the
not started or container exited. container is failed to start.
DT1002 Invalid target OS Unknown Dockerfile target OS Supported values are 'Windows'
specified in DockerDefaultTargetOS and 'Linux'.
property.
DT1006 The compose For example, if the active launch Update the launch profile to use
profile name used profile is using compose profile the right compose profile or use
in the active launch called p2 as shown here: the Manage Docker Compose
profile is not found Launch Settings dialog to
in the Docker "Docker Compose": { update the launch settings.
Compose "commandName": "DockerCompose",
document. "commandVersion": "1.0",
"composeProfile": {
"includes": [
"p2"
]
Code Description Notes Fix
}
}
DT1007 Invalid service name For example, if the active launch Update the launch profile to use
in the active launch profile is using compose profile p1 the right service name or use
profile that uses and defines the service list for the the Manage Docker Compose
compose profile. compose profile p1 as shown here: Launch Settings dialog to
update the launch settings.
"Docker Compose": {
"commandName": "DockerCompose",
"commandVersion": "1.0",
"composeProfile": {
"includes": [
"p1"
],
"serviceActions": {
"webapp2":
"StartWithoutDebugging"
}
}
}
but [Link] doesn't
define the service webapp2 , then you
see this error.
DT1008 Invalid service For example, if the active launch Correct the service action to
action in the active profile is using compose profile p1 StartWithoutDebugging , which is
launch profile that and defines the wrong action the only valid action for service
uses compose ( wrongActionname ) for a service that uses a compose profile.
profile. ( webapplication ).
"Docker Compose":
{ "commandName": "DockerCompose",
"commandVersion": "1.0",
"composeProfile": {
"includes": [
"p1"
],
"serviceActions": {
"webapp": "wrongActionname"
}
}
}
Code Description Notes Fix
DT1009 Active launch A Visual Studio launch profile can Use either composeProfile or
profile is using both be defined either using compose serviceActions or use the
composeProfile and profiles or picking and choosing a Manage Docker Compose
serviceActions . service list without using a compose Launch Settings dialog to
profile; it can't be created using update the launch settings.
both. So if an active launch profile
uses both as shown below, then you
see this error.
"Docker Compose": {
"commandName": "DockerCompose",
"commandVersion": "1.0",
"composeProfile": {
"includes": [
"p1"
]
},
"serviceActions": {
"webapp":
"StartWithoutDebugging"
}
}
DT1010 Invalid service name For example, if the active launch Update the launch profile to use
in the active launch profile defines the serviceActions the right service name or use
profile as shown here: the Manage Docker Compose
"Docker Compose": { Launch Settings dialog to
"commandName": "DockerCompose", update the launch settings.
"commandVersion": "1.0",
"serviceActions": {
"redis1":
"StartWithoutDebugging",
"webapp8":
"StartWithoutDebugging"
}
}
But the [Link] didn't
define the service redis1 , then you
will see this error.
DT1011 Invalid service For example, if the active launch Correct the service action to one
action in the active profile uses the wrong service of DoNotStart , StartDebugging ,
launch profile. action ( wrongAction ) as shown or StartWithoutDebugging . Or
below, then you will see this error. use Manage Docker Compose
"Docker Compose": { Launch Settings dialog to
"commandName": "DockerCompose", update the launch settings.
"commandVersion": "1.0",
Code Description Notes Fix
"serviceActions": {
"webapplication8":
"wrongAction"
}
}
DT1012 Invalid launch A Visual Studio launch profile can Use the Manage Docker
profile. Both be defined either using compose Compose Launch Settings
composeProfile and profiles or by picking and choosing dialog to update the launch
serviceActions are a service list without using a settings.
missing. compose profile. But the active
launch profile is defined with none
of them.
DT1014 Invalid profile For example, if the active launch Please see the error message for
version. profile defines an unknown the supported commandVersion ,
command version (10.0): or use the Manage Docker
"Docker Compose": Compose Launch Settings
"commandName": "DockerCompose", dialog to update the launch
"commandVersion": "10.0", settings.
"serviceActions": {
"webapp8": "StartDebugging",
"redis":
"StartWithoutDebugging"
}
}
DT1017 Using profile from This is a warning message The profile version is higher
newer version of than the current supported
Visual Studio, but version, but still compatible with
Code Description Notes Fix
DT1018 Using old profile This is a warning message The profile version is lower than
version, but the latest version, but still
compatible. compatible. Some of the newer
features might not work.
Consider upgrading to the latest
version of Visual Studio.
DT1019 Unsupported You are using older version of Upgrade Docker Compose to
compose v2 Docker Compose v2 that doesn't the latest version.
support the compose profile.
CTP1001 Unused
CTP1002 Unused
CTP1003 The container is absent or See the Output window for more detail on why
not running at the time of the container is failed to start.
debugging
CTP1006 Failed to stop the This is just a Make sure the application is not in use.
application within the warning.
container.
CTP1007 Unused
CTP1008 Unused
CTP1009 Failed to download Azure See the Output window for more detail.
Functions CLI
Last updated on 03/29/2024