title: Visual Studio 2019 - Docker 4.1.1 - Web App Stops Working After Adding Container Orchestration
body: <p>This is sort of strange. As soon as I add docker orchestration in Visual Studio 2019 my Web Application stops working. These are the exact steps that I am taking:</p>
  <ol>
  <li>Launch Visual Studio 2019 (16.11.3)</li>
  <li>Create new Project</li>
  <li>Select &quot;ASP.NET Core Web App&quot;, and click on Next</li>
  <li>Accept default Project Name and Location, and click on Next</li>
  <li>Specify, target framework as .NET 5.0 (Current), Auth Type: Individual Accounts, Check the box for Configure for HTTPS. At this moment I am not checking the Enable docker and enable razor runtime. Click on Create</li>
  <li>On the welcome screen click on Connected services, and configure on the Secrets.json (local) (finish, close that)</li>
  <li>Right-Click on my project, add, Container Orchestration Support</li>
  <li>Select &quot;Docker Compose&quot; as the orchestrator, and linux as the target os</li>
  <li>It appears that Visual Studio creates a docker-compose project to the solution, as well as some dockerfiles to the project. The output also shows that the containers are being built and eventually says they are ready.</li>
  </ol>
  <p>However my docker desktop shows them in this state</p>
  <p><a href="https://i.stack.imgur.com/jqF1q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jqF1q.png" alt="enter image description here" /></a></p>
  <p>The error shows as follows</p>
  <p><a href="https://i.stack.imgur.com/KM8t0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KM8t0.png" alt="enter image description here" /></a></p>
  <p>The text of that error shows:</p>
  <pre><code>warn: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[60]
  
        Storing keys in a directory '/root/.aspnet/DataProtection-Keys' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed.
  
  warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
  
        No XML encryptor configured. Key {a6907c05-45f2-4dc3-93ac-5d59ce2b2873} may be persisted to storage in unencrypted form.
  
  crit: Microsoft.AspNetCore.Server.Kestrel[0]
  
        Unable to start Kestrel.
  
        System.InvalidOperationException: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date.
  
        To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'.
  
        For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.
  
           at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions, Action`1 configureOptions)
  
           at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions)
  
           at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context)
  
           at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IEnumerable`1 listenOptions, AddressBindContext context)
  
           at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.BindAsync(CancellationToken cancellationToken)
  
           at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
  
  Unhandled exception. System.InvalidOperationException: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date.
  
  To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'.
  
  For more information on configuring HTTPS see https://go.microsoft.com/fwlink/?linkid=848054.
  
     at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions, Action`1 configureOptions)
  
     at Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(ListenOptions listenOptions)
  
     at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.BindAsync(AddressBindContext context)
  
     at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IEnumerable`1 listenOptions, AddressBindContext context)
  
     at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.BindAsync(CancellationToken cancellationToken)
  
     at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
  
     at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
  
     at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
  
     at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
  
     at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
  
     at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
  
     at WebApplication7.Program.Main(String[] args) in /src/WebApplication7/Program.cs:line 16
  </code></pre>
  <p>I was expecting since I didn't do anything custom yet that the orchestrator would just simply &quot;work&quot; at this point but it doesn't.</p>
  <p>I noticed that my Trust ASP.NET Core SSL certificate is &quot;Prompt Me&quot;, but I never receive the prompt</p>
  <p><a href="https://i.stack.imgur.com/Y1vH5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Y1vH5.png" alt="enter image description here" /></a></p>
  <p>I also try and do what is suggested in the error. So I press the trash can icon in my docker desktop for the orchestration. I then modify the Dockerfile inside of the project as follows, notice the extra run that I add before the entry point there.</p>
  <pre><code>#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
  
  FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
  WORKDIR /app
  EXPOSE 80
  EXPOSE 443
  
  FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
  WORKDIR /src
  COPY [&quot;WebApplication7/WebApplication7.csproj&quot;, &quot;WebApplication7/&quot;]
  RUN dotnet restore &quot;WebApplication7/WebApplication7.csproj&quot;
  COPY . .
  WORKDIR &quot;/src/WebApplication7&quot;
  RUN dotnet build &quot;WebApplication7.csproj&quot; -c Release -o /app/build
  
  FROM build AS publish
  RUN dotnet publish &quot;WebApplication7.csproj&quot; -c Release -o /app/publish
  
  FROM base AS final
  WORKDIR /app
  COPY --from=publish /app/publish .
  RUN dotnet dev-certs https
  ENTRYPOINT [&quot;dotnet&quot;, &quot;WebApplication7.dll&quot;]
  
  </code></pre>
  <p>I save the file and rebuild the solution and press the debug / start button (F5) for docker compose. It says the containers are ready again but now there are no ports exposed, thus no where to browse to, and no logs. I can access the cli for the container but that's it.</p>
  <p><a href="https://i.stack.imgur.com/yxEnK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yxEnK.png" alt="enter image description here" /></a></p>
  <p>What am I doing wrong? Why is this not just simply working OOB with Visual Studio?</p>
  <p>Something that does work though is if I take that extra RUN line out of my Dockerfile that I added, then set my web project as the startup project, I am able to debug and run that. But again, once I set the docker-compose project as the startup project and try to debug that, I am dead in the water again.</p>