Originally I was using Visual Studio 2017 Tools for Docker as this was the default in earlier versions of Visual Studio when adding docker support to ASP.NET.
Recently I upgraded to Visual Studio 2017 15.8.0 Preview 2 and I noticed there is a completely new way of doing docker builds using launchSettings.json
.
The old way had a special *.dcproj
whos project's SDK attribute pointed to <Project Sdk="Microsoft.NET.Sdk.Web">
. Inside this project, there was a docker-compose.yml
and a docker-compose.override.yml
that pointed to my ASP.Net's Dockerfile
. This was very flexible allowed me to do tons of customization like adding a volume mount as follows.
docker-compose.override.yml:
version: '3.5'
services:
sample.container:
volumes:
- type: bind
source: C:\config
target: /config
read_only: true
volume:
nocopy: true
This was great as it allowed me to easily point to a config file that was not in the container during debugging.
Now with the new docker tooling in visual studio using launchSettings.json
and <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="0.2.1686908" />
in the *.csproj
file the compose files are no longer used, it launches the Dockerfile
directly. Below is a copy of my launchSettings.json
.
I'm really hoping someone can tell me how to add a custom volume mount this new way into the launchSettings.json
file, see the Docker
section below.
launchSettings.json:
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:55836",
"sslPort": 44354
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"WebApplication1": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://localhost:{ServicePort}"
}
}
}
I would also like to say I've been searching for the solution to this problem for several hours now and I've not been able to find any information on the subject.
To attach to a running process in a Windows Docker container: In Visual Studio, select Debug > Attach to Process (or CTRL+ALT+P) to open the Attach to Process dialog box. Set the Connection type to Docker (Windows Container). Select Find... to set the Connection target using the Select Docker Container dialog box.
There are a couple of MSBuild properties that can be used to augment the build/run of a Docker image:
DockerfileBuildArguments
: Additional arguments passed to the Docker build command.DockerfileRunArguments
: Additional arguments passed to the Docker run command.Example:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<DockerfileRunArguments>-v "C:\HostFolder:/ContainerFolder:ro"</DockerfileRunArguments>
</PropertyGroup>
</Project>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With