You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The preceding *Dockerfile* is based on the [Microsoft Container Registry (MCR)](https://azure.microsoft.com/blog/microsoft-syndicates-container-catalog/) .NET 6 image image, and includes instructions for modifying the base image by building your project and adding it to the container. If you're using the .NET Framework, the base image will be different.
73
+
The preceding *Dockerfile* is based on the [Microsoft Container Registry (MCR)](https://azure.microsoft.com/blog/microsoft-syndicates-container-catalog/) .NET 6 image and includes instructions for modifying the base image by building your project and adding it to the container. If you're using the .NET Framework, the base image will be different.
75
74
76
75
When the new project dialog's **Configure for HTTPS** check box is checked, the *Dockerfile* exposes two ports. One port is used for HTTP traffic; the other port is used for HTTPS. If the check box isn't checked, a single port (80) is exposed for HTTP traffic.
77
76
77
+
With Visual Studio 2022 version 17.7 or later, you can target [.NET 8 preview](https://dotnet.microsoft.com/download/). In that case, 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 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:
78
+
79
+
```dockerfile
80
+
FROM mcr.microsoft.com/dotnet/aspnet:8.0-preview AS base
81
+
USER app
82
+
WORKDIR /app
83
+
EXPOSE 8080
84
+
EXPOSE 8081
85
+
```
86
+
78
87
## Debug
79
88
80
89
Select **Docker** from the debug drop-down 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.
-[Visual Studio 2022](https://visualstudio.microsoft.com/downloads) or [Visual Studio 2019 version 16.4](https://visualstudio.microsoft.com/downloads) or later.
29
+
- For the Docker Compose node, [Visual Studio 2022 version 17.7 or later](https://visualstudio.microsoft.com/downloads) and Docker v2, which is installed with Docker Desktop and on by default.
29
30
30
31
:::moniker-end
31
32
@@ -45,9 +46,16 @@ On the left side, you see the list of containers on your local machine. The cont
45
46
> [!TIP]
46
47
> You can easily customize where the **Containers** tool window is docked in Visual Studio. See [Customizing window layouts in Visual Studio](../ide/customizing-window-layouts-in-visual-studio.md). By default, the **Containers** window is docked with the **Watch** window when the debugger is running.
47
48
49
+
:::moniker range=">=vs-2022"
50
+
51
+
If you're using Docker Compose and Visual Studio 2022 version 17.7 or later, you see a tree of nodes for your solution and its Docker Compose project, with a parent node for the solution and child nodes for each project, as you can see the following image:
52
+
53
+

54
+
:::moniker-end
55
+
48
56
## View environment variables
49
57
50
-
The **Environment** tab shows the environment variables in the container. For your app's container, you can set these variables in many ways, for example, in the Dockerfile, in a .env file, or by using the -e option when you start a container using a Docker command.
58
+
The **Environment** tab shows the environment variables in the container. For your app's container, you can set these variables in many ways, for example, in the Dockerfile, in an .env file, or by using the -e option when you start a container using a Docker command.
51
59
52
60
:::moniker range="vs-2019"
53
61

@@ -94,7 +102,7 @@ The **Volumes** tab shows the volumes (mounted filesystem nodes) on the containe
94
102
95
103
## View logs
96
104
97
-
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](https://docs.docker.com/config/containers/logging/). By default, the **Logs** tab streams the logs, but you can disable that by choosing the **Stop** button on the tab.
105
+
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](https://docs.docker.com/config/containers/logging/). By default, the **Logs** tab streams the logs, but you can pause that by choosing the **Stream** button on the tab. If you press **Stream** again, the streaming resumes from where it left off.
98
106
99
107
:::moniker range="vs-2019"
100
108

@@ -108,6 +116,12 @@ To clear the logs, use the **Clear** button on the **Logs** tab. To get all the
108
116
> [!NOTE]
109
117
> Visual Studio automatically redirects stdout and stderr to the **Output** window when you run without debugging with Windows containers, so Windows containers started from Visual Studio using **Ctrl**+**F5** will not display logs in this tab; use the **Output** window instead.
110
118
119
+
:::moniker range=">=vs-2022"
120
+
If you're using Docker Compose with Visual Studio 2022 version 17.7 or later, you have the option of viewing 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 by itself, select that specific project's node.
121
+
122
+

123
+
:::moniker-end
124
+
111
125
## View the filesystem
112
126
113
127
On the **Files** tab, you can view the container's filesystem, including the app folder that contains your project.
@@ -130,6 +144,10 @@ To open files in Visual Studio, browse to the file and double-click it, or right
130
144
131
145
Using the **Files** tab, you can view application logs such as IIS logs, configuration files, and other content files in your container's filesystem.
132
146
147
+
:::moniker range=">=vs-2022"
148
+
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 normal user permissions. The **Files** tab uses those permissions as well, and so you might not be able to view some folders, if those folders are set to require elevated permissions to view.
149
+
:::moniker-end
150
+
133
151
## Start, stop, and remove containers
134
152
135
153
By default, the **Containers** window shows all containers on the machine that Docker manages. You can use the toolbar buttons to start, stop, or remove (delete) a container you no longer want. This list is dynamically updated as containers are created or removed.
@@ -156,6 +174,10 @@ For Windows containers, the Windows command prompt opens. For Linux containers,
156
174

157
175
:::moniker-end
158
176
177
+
:::moniker range=">=vs-2022"
178
+
If you're targeting .NET 8, your Dockerfile can specify the `USER app` command, which means your app runs with normal user permissions, rather than elevated permissions. The Dockerfile generated by Visual Studio includes this in Visual Studio 2022 version 17.7 and later, if you're targeting .NET 8 or later. The terminal opens as the user specified in the Dockerfile (by default for .NET 8 projects, that's `app`), or if no user is specified, it runs as the `root` user.
179
+
:::moniker-end
180
+
159
181
Normally, the terminal window opens outside Visual Studio as a separate window. If you want a command-line environment integrated into the Visual Studio IDE as a dockable tool window, you can install [Whack Whack Terminal](https://marketplace.visualstudio.com/items?itemName=DanielGriffen.WhackWhackTerminal).
0 commit comments