dotnet / aspire

An opinionated, cloud ready stack for building observable, production ready, distributed applications in .NET
https://learn.microsoft.com/dotnet/aspire
MIT License
3.55k stars 389 forks source link

Errors running Aspire on Ubuntu 24.04 #3859

Open wgrs opened 4 months ago

wgrs commented 4 months ago

Following the instructions from https://learn.microsoft.com/en-us/dotnet/aspire/get-started/build-your-first-aspire-app?tabs=visual-studio

This is the error message:

warn: Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer[8]
      The ASP.NET Core developer certificate is not trusted. For information about trusting the ASP.NET Core developer certificate, see https://aka.ms/aspnet/https-trust-dev-cert.
info: Aspire.Hosting.DistributedApplication[0]
      Aspire version: 8.0.0-preview.5.24201.12+1b627b7d5d399d4f9118366e7611e11e56de4554
info: Aspire.Hosting.DistributedApplication[0]
      Distributed application starting.
info: Aspire.Hosting.DistributedApplication[0]
      Application host directory is: /home/greg/MyDev/Sandbox/AspireSample/AspireSample.AppHost
fail: Microsoft.Extensions.Hosting.Internal.Host[11]
      Hosting failed to start
      Aspire.Hosting.DistributedApplicationException: Container runtime 'docker' was found but appears to be unhealthy. The error from the container runtime check was Cannot connect to the Docker daemon at unix:///home/greg/.docker/desktop/docker.sock. Is the docker daemon running?.
         at Aspire.Hosting.Dcp.DcpDependencyCheck.EnsureDcpContainerRuntime(DcpInfo dcpInfo) in /_/src/Aspire.Hosting/Dcp/DcpDependencyCheck.cs:line 199
         at Aspire.Hosting.Dcp.DcpDependencyCheck.GetDcpInfoAsync(CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Dcp/DcpDependencyCheck.cs:line 99
         at Aspire.Hosting.Dcp.DcpDependencyCheck.GetDcpInfoAsync(CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Dcp/DcpDependencyCheck.cs:line 115
         at Aspire.Hosting.Dcp.DcpHostService.StartAsync(CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Dcp/DcpHostService.cs:line 67
         at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>b__15_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)
Unhandled exception. System.AggregateException: One or more errors occurred. (Container runtime 'docker' was found but appears to be unhealthy. The error from the container runtime check was Cannot connect to the Docker daemon at unix:///home/greg/.docker/desktop/docker.sock. Is the docker daemon running?.)
 ---> Aspire.Hosting.DistributedApplicationException: Container runtime 'docker' was found but appears to be unhealthy. The error from the container runtime check was Cannot connect to the Docker daemon at unix:///home/greg/.docker/desktop/docker.sock. Is the docker daemon running?.
   at Aspire.Hosting.Dcp.DcpDependencyCheck.EnsureDcpContainerRuntime(DcpInfo dcpInfo) in /_/src/Aspire.Hosting/Dcp/DcpDependencyCheck.cs:line 199
   at Aspire.Hosting.Dcp.DcpDependencyCheck.GetDcpInfoAsync(CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Dcp/DcpDependencyCheck.cs:line 99
   at Aspire.Hosting.Dcp.DcpDependencyCheck.GetDcpInfoAsync(CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Dcp/DcpDependencyCheck.cs:line 115
   at Aspire.Hosting.Dcp.DcpHostService.StartAsync(CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Dcp/DcpHostService.cs:line 67
   at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>b__15_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 Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
   at Aspire.Hosting.DistributedApplication.RunAsync(CancellationToken cancellationToken) in /_/src/Aspire.Hosting/DistributedApplication.cs:line 102
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait()
   at Aspire.Hosting.DistributedApplication.Run() in /_/src/Aspire.Hosting/DistributedApplication.cs:line 110
   at Program.<Main>$(String[] args) in /home/greg/MyDev/Sandbox/AspireSample/AspireSample.AppHost/Program.cs:line 11
asimmon commented 4 months ago

Docker must be up and running

timheuer commented 4 months ago

We have seen this a bit in a few cases, as @asimmon notes, where the daemon is actually not running, but also in some cases where Docker has gone into different types of power-saver modes (mostly seeing this on Windows). @wgrs can you confirm docker is running? eg. running docker ps -a or other docker ps commands?

wgrs commented 4 months ago

@timheuer @asimmon

Docker running now - same error when I try to run AppHost

Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world c1ec31eb5944: Pull complete Digest: sha256:a26bff933ddc26d5cdf7faa98b4ae1e3ec20c4985e6f87ac0973052224d24302 Status: Downloaded newer image for hello-world:latest

Hello from Docker! This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:

  1. The Docker client contacted the Docker daemon.
  2. The Docker daemon pulled the "hello-world" image from the Docker Hub. (amd64)
  3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading.
  4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal.

To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/

For more examples and ideas, visit: https://docs.docker.com/get-started/

systemctl status docker ● docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; preset: enabled) Active: active (running) since Mon 2024-04-22 10:09:53 CEST; 33min ago TriggeredBy: ● docker.socket Docs: https://docs.docker.com Main PID: 1830 (dockerd) Tasks: 11 Memory: 110.9M (peak: 114.8M) CPU: 1.897s CGroup: /system.slice/docker.service └─1830 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Apr 22 10:09:52 greg-ThinkPad-E520 dockerd[1830]: time="2024-04-22T10:09:52.737918847+02:00" level=info msg="detected 1> Apr 22 10:09:52 greg-ThinkPad-E520 dockerd[1830]: time="2024-04-22T10:09:52.863110380+02:00" level=info msg="[graphdriv> Apr 22 10:09:52 greg-ThinkPad-E520 dockerd[1830]: time="2024-04-22T10:09:52.864557958+02:00" level=info msg="Loading co> Apr 22 10:09:53 greg-ThinkPad-E520 dockerd[1830]: time="2024-04-22T10:09:53.272497256+02:00" level=info msg="Default br> Apr 22 10:09:53 greg-ThinkPad-E520 dockerd[1830]: time="2024-04-22T10:09:53.368187256+02:00" level=info msg="Loading co> Apr 22 10:09:53 greg-ThinkPad-E520 dockerd[1830]: time="2024-04-22T10:09:53.391874926+02:00" level=info msg="Docker dae> Apr 22 10:09:53 greg-ThinkPad-E520 dockerd[1830]: time="2024-04-22T10:09:53.392617742+02:00" level=info msg="Daemon has> Apr 22 10:09:53 greg-ThinkPad-E520 dockerd[1830]: time="2024-04-22T10:09:53.452520961+02:00" level=info msg="API listen> Apr 22 10:09:53 greg-ThinkPad-E520 systemd[1]: Started docker.service - Docker Application Container Engine. Apr 22 10:37:43 greg-ThinkPad-E520 dockerd[1830]: time="2024-04-22T10:37:43.586500771+02:00" level=info msg="ignoring e> lines 1-22/22 (END)

wgrs commented 4 months ago

Docker must be up and running

@asimmon

I also tried to get the Dev Certificate to work on Edge - I followed the instructions you posted but I have never been able to stop the cert error. The instructions or scripts are incorrect. This has been an issue for at least 2 years.

wgrs commented 4 months ago

@asimmon @timheuer

When I run systemctl status docker, I get the message above - but when I run the Aspire AppHost i get

Hosting failed to start Aspire.Hosting.DistributedApplicationException: Container runtime 'docker' was found but appears to be unhealthy. The error from the container runtime check was Cannot connect to the Docker daemon at unix:///home/greg/.docker/desktop/docker.sock. Is the docker daemon running?.

However, when I run sudo systemctl status docker, I get Apr 22 15:46:44 greg-ThinkPad-E520 dockerd[10078]: time="2024-04-22T15:46:44.365034068+02:00" level=info msg="API listen on /run/docker.sock"

My question : Where should Aspire be looking for the docker.socket ?

timheuer commented 4 months ago

@danegsta any ideas on the Docker error here?

danegsta commented 4 months ago

@wgrs from that output, it looks like you may have both Docker Desktop for Linux installed as well as Docker CE (the open source community edition version), hence the two different sockets. Somehow the terminal is seeing the environment config for Docker CE, but however you’re running Aspire is seeing the environment config for Docker Desktop (which may not be running, hence the error).

Are you using a terminal or an IDE to run Aspire?

wgrs commented 4 months ago

@danegsta I'm running dotnet run from terminal. I've tried both Docker Desktop install as well as Docker Engine from docker docs. Neither install works with Aspire.

Can you point me to a installation guide that can be followed that actually works?

danegsta commented 4 months ago

Aspire uses the Docker CLI to run commands, rather than communicating with a Docker socket, so any commands we run will honor the environment configuration Aspire was launched with. So if you were to run a Docker command such as docker info from the same terminal window, I would expect it to run with the same socket settings (and report a similar error if the socket isn’t responding). Can you share the output of running docker info (double check for any information in the output you’d like to redact; it’s fairly innocuous, but will include file paths to things like your docker socket)? That will indicate what settings Docker is using from the command line by default.

wgrs commented 4 months ago

@danegsta

docker info is just hanging. So, I will completely nuke docker and do a fresh install of docker desktop as per their docs. ( for the 8th time)

danegsta commented 4 months ago

Also, try running echo $DOCKER_HOST to see what value it reports and running docker context ls to see if you have multiple contexts configured. If you have multiple contexts and one is referencing the working socket, you can make that the default with docker context use <context-name>. If you don’t have a context with the correct socket, you can try running aspire with DOCKER_HOST=/run/docker.sock dotnet run …` to force Docker to use the good socket and see if that works to run without error. If it does, you can create a new context to point to the good socket and make Docker use that: https://docs.docker.com/engine/context/working-with-contexts/

wgrs commented 4 months ago

@danegsta

docker info Client: Docker Engine - Community Version: 26.0.2 Context: desktop-linux Debug Mode: false Plugins: buildx: Docker Buildx (Docker Inc.) Version: v0.13.1-desktop.1 Path: /usr/lib/docker/cli-plugins/docker-buildx compose: Docker Compose (Docker Inc.) Version: v2.26.1-desktop.1 Path: /usr/lib/docker/cli-plugins/docker-compose debug: Get a shell into any image or container. (Docker Inc.) Version: 0.0.27 Path: /usr/lib/docker/cli-plugins/docker-debug dev: Docker Dev Environments (Docker Inc.) Version: v0.1.2 Path: /usr/lib/docker/cli-plugins/docker-dev extension: Manages Docker extensions (Docker Inc.) Version: v0.2.23 Path: /usr/lib/docker/cli-plugins/docker-extension feedback: Provide feedback, right in your terminal! (Docker Inc.) Version: v1.0.4 Path: /usr/lib/docker/cli-plugins/docker-feedback init: Creates Docker-related starter files for your project (Docker Inc.) Version: v1.1.0 Path: /usr/lib/docker/cli-plugins/docker-init sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.) Version: 0.6.0 Path: /usr/lib/docker/cli-plugins/docker-sbom scout: Docker Scout (Docker Inc.) Version: v1.6.3 Path: /usr/lib/docker/cli-plugins/docker-scout

Server: ERROR: Cannot connect to the Docker daemon at unix:///home/greg/.docker/desktop/docker.sock. Is the docker daemon running? errors pretty printing info

wgrs commented 4 months ago

@danegsta

echo $DOCKER_HOST returns a blank line

docker context ls NAME TYPE DESCRIPTION DOCKER ENDPOINT KUBERNETES ENDPOINT ORCHESTRATOR default moby Current DOCKER_HOST based configuration unix:///var/run/docker.sock
desktop-linux * moby Docker Desktop unix:///home/greg/.docker/desktop/docker.sock

danegsta commented 4 months ago

@wgrs docker context use default should hopefully get you working.

danegsta commented 4 months ago

That looks like the Docker CE context which seems to be working based on your systemctl output.

wgrs commented 4 months ago

@danegsta

I ran: docker context use default

I started docker desktop : systemctl --user start docker-desktop

ran the Aspire Starter .... same error -

dotnet run Building... /home/greg/MyDev/Sandbox/AspireSample/AspireSample.ServiceDefaults/AspireSample.ServiceDefaults.csproj : warning NU1902: Package 'OpenTelemetry.Instrumentation.AspNetCore' 1.7.1 has a known moderate severity vulnerability, https://github.com/advisories/GHSA-vh2m-22xx-q94f [/home/greg/MyDev/Sandbox/AspireSample/AspireSample.AppHost/AspireSample.AppHost.csproj] /home/greg/MyDev/Sandbox/AspireSample/AspireSample.ServiceDefaults/AspireSample.ServiceDefaults.csproj : warning NU1902: Package 'OpenTelemetry.Instrumentation.Http' 1.7.1 has a known moderate severity vulnerability, https://github.com/advisories/GHSA-vh2m-22xx-q94f [/home/greg/MyDev/Sandbox/AspireSample/AspireSample.AppHost/AspireSample.AppHost.csproj] /home/greg/MyDev/Sandbox/AspireSample/AspireSample.ServiceDefaults/AspireSample.ServiceDefaults.csproj : warning NU1902: Package 'OpenTelemetry.Instrumentation.AspNetCore' 1.7.1 has a known moderate severity vulnerability, https://github.com/advisories/GHSA-vh2m-22xx-q94f /home/greg/MyDev/Sandbox/AspireSample/AspireSample.ServiceDefaults/AspireSample.ServiceDefaults.csproj : warning NU1902: Package 'OpenTelemetry.Instrumentation.Http' 1.7.1 has a known moderate severity vulnerability, https://github.com/advisories/GHSA-vh2m-22xx-q94f warn: Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer[8] The ASP.NET Core developer certificate is not trusted. For information about trusting the ASP.NET Core developer certificate, see https://aka.ms/aspnet/https-trust-dev-cert. info: Aspire.Hosting.DistributedApplication[0] Aspire version: 8.0.0-preview.5.24201.12+1b627b7d5d399d4f9118366e7611e11e56de4554 info: Aspire.Hosting.DistributedApplication[0] Distributed application starting. info: Aspire.Hosting.DistributedApplication[0] Application host directory is: /home/greg/MyDev/Sandbox/AspireSample/AspireSample.AppHost fail: Microsoft.Extensions.Hosting.Internal.Host[11] Hosting failed to start Aspire.Hosting.DistributedApplicationException: Application orchestrator dependency check had an unexpected error System.TimeoutException: The operation has timed out. at Aspire.Hosting.Dcp.DcpDependencyCheck.GetDcpInfoAsync(CancellationToken cancellationToken) in //src/Aspire.Hosting/Dcp/DcpDependencyCheck.cs:line 78. at Aspire.Hosting.Dcp.DcpDependencyCheck.GetDcpInfoAsync(CancellationToken cancellationToken) in //src/Aspire.Hosting/Dcp/DcpDependencyCheck.cs:line 105 at Aspire.Hosting.Dcp.DcpDependencyCheck.GetDcpInfoAsync(CancellationToken cancellationToken) in //src/Aspire.Hosting/Dcp/DcpDependencyCheck.cs:line 115 at Aspire.Hosting.Dcp.DcpHostService.StartAsync(CancellationToken cancellationToken) in //src/Aspire.Hosting/Dcp/DcpHostService.cs:line 67 at Microsoft.Extensions.Hosting.Internal.Host.b151(IHostedService service, CancellationToken token) at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable1 services, CancellationToken token, Boolean concurrent, Boolean abortOnFirstException, List1 exceptions, Func`3 operation) Unhandled exception. System.AggregateException: One or more errors occurred. (Application orchestrator dependency check had an unexpected error System.TimeoutException: The operation has timed out. at Aspire.Hosting.Dcp.DcpDependencyCheck.GetDcpInfoAsync(CancellationToken cancellationToken) in //src/Aspire.Hosting/Dcp/DcpDependencyCheck.cs:line 78.) ---> Aspire.Hosting.DistributedApplicationException: Application orchestrator dependency check had an unexpected error System.TimeoutException: The operation has timed out. at Aspire.Hosting.Dcp.DcpDependencyCheck.GetDcpInfoAsync(CancellationToken cancellationToken) in //src/Aspire.Hosting/Dcp/DcpDependencyCheck.cs:line 78. at Aspire.Hosting.Dcp.DcpDependencyCheck.GetDcpInfoAsync(CancellationToken cancellationToken) in //src/Aspire.Hosting/Dcp/DcpDependencyCheck.cs:line 105 at Aspire.Hosting.Dcp.DcpDependencyCheck.GetDcpInfoAsync(CancellationToken cancellationToken) in //src/Aspire.Hosting/Dcp/DcpDependencyCheck.cs:line 115 at Aspire.Hosting.Dcp.DcpHostService.StartAsync(CancellationToken cancellationToken) in //src/Aspire.Hosting/Dcp/DcpHostService.cs:line 67 at Microsoft.Extensions.Hosting.Internal.Host.b151(IHostedService service, CancellationToken token) at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable1 services, CancellationToken token, Boolean concurrent, Boolean abortOnFirstException, List1 exceptions, Func`3 operation) 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 Aspire.Hosting.DistributedApplication.RunAsync(CancellationToken cancellationToken) in //src/Aspire.Hosting/DistributedApplication.cs:line 102 --- End of inner exception stack trace --- at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at System.Threading.Tasks.Task.Wait() at Aspire.Hosting.DistributedApplication.Run() in /_/src/Aspire.Hosting/DistributedApplication.cs:line 110 at Program.

$(String[] args) in /home/greg/MyDev/Sandbox/AspireSample/AspireSample.AppHost/Program.cs:line 11

wgrs commented 4 months ago

@timheuer @danegsta

Just tried to spin up the dev containers tutorial - when running the "open in container" command in vscode, the "Starting Docker" dialog opens and just hangs. No timeouts, no warnings or errors. Surely if vscode cant start docker, there should at least be a timeout?

timheuer commented 4 months ago

Did you install the Aspire workload -- the latest error isn't showing the 'docker unhealthy' anymore but a diff dependency check.

What is the output of dotnet --info and dotnet workload list

wgrs commented 3 months ago

@timheuer

dotnet workload list

Installed Workload Id Manifest Version Installation Source

aspire 8.0.0-preview.5.24201.12/8.0.100 SDK 8.0.100

Use dotnet workload search to find additional workloads to install.

Updates are available for the following workload(s): aspire. Run dotnet workload update to get the latest.

dotnet --info .NET SDK: Version: 8.0.104 Commit: 034f91fcc0 Workload version: 8.0.100-manifests.2f72bdd4

Runtime Environment: OS Name: ubuntu OS Version: 24.04 OS Platform: Linux RID: ubuntu.24.04-x64 Base Path: /usr/lib/dotnet/sdk/8.0.104/

.NET workloads installed: Workload version: 8.0.100-manifests.2f72bdd4 [aspire] Installation Source: SDK 8.0.100 Manifest Version: 8.0.0-preview.5.24201.12/8.0.100 Manifest Path: /home/greg/.dotnet/sdk-manifests/8.0.100/microsoft.net.sdk.aspire/8.0.0-preview.5.24201.12/WorkloadManifest.json Install Type: FileBased

Host: Version: 8.0.4 Architecture: x64 Commit: 2d7eea2529

.NET SDKs installed: 8.0.104 [/usr/lib/dotnet/sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 8.0.4 [/usr/lib/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 8.0.4 [/usr/lib/dotnet/shared/Microsoft.NETCore.App]

Other architectures found: None

Environment variables: Not set

global.json file: Not found

Learn more: https://aka.ms/dotnet/info

Download .NET: https://aka.ms/dotnet/download

timheuer commented 3 months ago

@danegsta the last exception no longer looks like the 'docker is unhealthy' one but another dependency check. I thought maybe the workload wasn't installed but looks like p5 is there.

jiimaho commented 2 months ago

Any updates on this? Getting the same error on MacOS

davidfowl commented 2 months ago

Can you share the exact error you’re hitting ?