Skip to content

Hosting failed to start inside VS Code dev container with quickstart #17354

Description

@erwinkramer

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Hosting failed to start inside VS Code Dev Container with the Aspire quickstart.

Locally, without dev container setup, but with the quickstart, I don't have an issue.

Expected Behavior

Should just run.

Steps To Reproduce

Start Docker Desktop Version 4.74.0 (227015) on Windows (11), enable WSL integration in the Docker Desktop settings.

Make a project with the quickstart:

aspire new aspire-starter -n AspireApp -o AspireApp

Then add the devcontainer setup from: https://github.com/microsoft/aspire-devcontainer/blob/main/.devcontainer/devcontainer.json

I omitted some parts from the config sample, so it looks like:

{
	"name": "Aspire",
	// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
	"image": "mcr.microsoft.com/devcontainers/dotnet:dev-10.0-noble",
	"features": {
		"ghcr.io/microsoft/aspire-devcontainer-feature/aspire:2": {},
		"ghcr.io/devcontainers/features/docker-in-docker:2": {}
	},
	// Use 'forwardPorts' to make a list of ports inside the container available locally.
	// "forwardPorts": [5000, 5001],
	// "portsAttributes": {
	//		"5001": {
	//			"protocol": "https"
	//		}
	// }

	// Use 'postCreateCommand' to run commands after the container is created.
	// "postCreateCommand": "dotnet restore",
	"postStartCommand": "dotnet dev-certs https --trust",
	"customizations": {
		"vscode": {
			"extensions": [
				"ms-dotnettools.csdevkit",
				"GitHub.copilot-chat",
				"microsoft-aspire.aspire-vscode"
			]
		}
	}
}

Then reopen in dev container (vscode), and run the AppHost project.

Exceptions (if any)

📂  Launching Aspire debug session for AppHost /workspaces/New folder/HelloAspire/HelloAspire.AppHost/AppHost.cs...
Finding AppHosts...
HelloAspire.AppHost.csproj
🔐 Trusting certificates...
⚠️ Developer certificates may not be fully trusted (trust exit code was: PartiallyFailedToTrustTheCertificate).
🛠️ Building AppHost... HelloAspire.AppHost.csproj
🔬 Checking project type...: HelloAspire.AppHost.csproj
Connecting to AppHost...
info: Aspire.Hosting.DistributedApplication[0]
      Aspire version: 13.3.5+70b33bcb5f64c75e3ab6f57616545f35bd43dc81
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application starting.
info: Aspire.Hosting.DistributedApplication[0]
      Application host directory is: /workspaces/New folder/HelloAspire/HelloAspire.AppHost
warn: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[60]
      Storing keys in a directory '/home/vscode/.aspnet/DataProtection-Keys' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed. For more information go to https://aka.ms/aspnet/dataprotectionwarning
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
      No XML encryptor configured. Key {3d571bdf-60f9-470c-87e0-865b88cec534} may be persisted to storage in unencrypted form.
fail: Microsoft.Extensions.Hosting.Internal.Host[11]
      Hosting failed to start
      System.Threading.Tasks.TaskCanceledException: A task was canceled.
         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>b__14_1(IHostedService service, CancellationToken token)
         at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable`1 services, CancellationToken token, Boolean concurrent, Boolean abortOnFirstException, List`1 exceptions, Func`3 operation)
fail: Microsoft.Extensions.Hosting.Internal.Host[11]
      Hosting failed to start
      System.Threading.Tasks.TaskCanceledException: A task was canceled.
         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>b__14_1(IHostedService service, CancellationToken token)
         at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable`1 services, CancellationToken token, Boolean concurrent, Boolean abortOnFirstException, List`1 exceptions, Func`3 operation)
         at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
         at Aspire.Hosting.Dashboard.DashboardServiceHost.Microsoft.Extensions.Hosting.IHostedService.StartAsync(CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Dashboard/DashboardServiceHost.cs:line 205
         at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>b__14_1(IHostedService service, CancellationToken token)
         at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable`1 services, CancellationToken token, Boolean concurrent, Boolean abortOnFirstException, List`1 exceptions, Func`3 operation)
ℹ️  The AppHost process has terminated. To view console output, select the AppHost session from the debug console dropdown.
🔌  Disconnecting from Aspire debug session... Child processes will be stopped.

Aspire doctor output

This is the output when running the command inside the dev container from vs code.

Aspire Environment Check
========================

.NET SDK
  ✅ .NET 10.0.300 installed (x64)  

Container Runtime
  ✅ Docker: running (auto-detected (default)) ← active  

Environment
  ✅ WSL2 environment detected  
       Details:                                                                                                 
       If you experience container connectivity issues, ensure Docker Desktop WSL integration is enabled.       
  ⚠️ HTTPS development certificate is only partially trusted  
       Set SSL_CERT_DIR in your shell profile: export                                                                      
       SSL_CERT_DIR="$SSL_CERT_DIR:/usr/lib/ssl/certs:/home/vscode/.aspnet/dev-certs/trust"                                
       See: https://aka.ms/aspire-prerequisites#dev-certs                                                                  
       Details:                                                                                                            
       The certificate is in the trusted store, but SSL_CERT_DIR is not configured to include                              
       '/home/vscode/.aspnet/dev-certs/trust'. Some applications may not trust the certificate. 'aspire run' will          
       configure this automatically.                                                                                       

Summary: 3 passed, 1 warnings, 0 failed
For detailed prerequisites: https://aka.ms/aspire-prerequisites

Anything else?

Also tried the podman setup, until I got hit with the same Hosting failed to start. It required me to use the following VS Code settings before I got there:

    "dev.containers.dockerPath": "podman",
    "dev.containers.dockerComposePath": "podman compose",
    "dev.containers.mountWaylandSocket": false,

And the following extra devcontainer setting:

   "remoteUser": "root"

Using podman version 5.8.2

Also tried .NET 11 preview, via mcr.microsoft.com/devcontainers/dotnet:dev-11.0-preview-resolute, which works great for .NET 11 projects, except for Aspire, giving the same host failed to start message.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-app-modelIssues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplicationarea-dashboardtriage:bot-seenAspire triage bot has seen this issue

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions