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.38k stars 351 forks source link

Custom Docker Host does not work #1650

Open AceHack opened 5 months ago

AceHack commented 5 months ago

My docker host is set to DOCKER_HOST=tcp://10.211.55.2:12675

When I try the starter app it's unable to connect to redis because it's expecting it to be on localhost I think but it's not, it's on the custom host.

StackExchange.Redis.RedisConnectionException: The message timed out in the backlog attempting to send because no connection became available (5000ms) - Last Connection Exception: SocketFailure (ReadSocketError/ConnectionReset, 0-read, last-recv: 0) on localhost:51021/Interactive, Flushed/Faulted, last: ECHO, origin: ReadFromPipe, outstanding: 12, last-read: 0s ago, last-write: 0s ago, unanswered-write: 0s ago, keep-alive: 60s, state: ConnectedEstablishing, mgr: 9 of 10 available, last-heartbeat: never, global: 0s ago, v: 2.7.4.20928, command=GET, timeout: 5000, inst: 0, qu: 0, qs: 12, aw: False, bw: CheckingForTimeout, rs: ReadAsync, ws: Flushed, in: 0, in-pipe: 0, out-pipe: 0, last-in: 0, cur-in: 0, sync-ops: 0, async-ops: 1, serverEndpoint: localhost:51021, conn-sec: 1.01, aoc: 0, mc: 1/1/0, mgr: 10 of 10 available, clientName: ACEPARALLELS(SE.Redis-v2.7.4.20928), IOCP: (Busy=0,Free=1000,Min=1,Max=1000), WORKER: (Busy=0,Free=32767,Min=8,Max=32767), POOL: (Threads=7,QueuedItems=0,CompletedItems=678,Timers=11), v: 2.7.4.20928 (Please take a look at this article for some common client-side issues that can cause timeouts: https://stackexchange.github.io/StackExchange.Redis/Timeouts)
 ---> StackExchange.Redis.RedisConnectionException: SocketFailure (ReadSocketError/ConnectionReset, 0-read, last-recv: 0) on localhost:51021/Interactive, Flushed/Faulted, last: ECHO, origin: ReadFromPipe, outstanding: 12, last-read: 0s ago, last-write: 0s ago, unanswered-write: 0s ago, keep-alive: 60s, state: ConnectedEstablishing, mgr: 9 of 10 available, last-heartbeat: never, global: 0s ago, v: 2.7.4.20928
 ---> Pipelines.Sockets.Unofficial.ConnectionResetException: An existing connection was forcibly closed by the remote host.
 ---> System.Net.Sockets.SocketException (10054): An existing connection was forcibly closed by the remote host.
   at Pipelines.Sockets.Unofficial.Internal.Throw.Socket(Int32 errorCode) in /_/src/Pipelines.Sockets.Unofficial/Internal/Throw.cs:line 59
   at Pipelines.Sockets.Unofficial.SocketAwaitableEventArgs.<GetResult>g__ThrowSocketException|10_0(SocketError e) in /_/src/Pipelines.Sockets.Unofficial/SocketAwaitableEventArgs.cs:line 86
   at Pipelines.Sockets.Unofficial.SocketAwaitableEventArgs.GetResult() in /_/src/Pipelines.Sockets.Unofficial/SocketAwaitableEventArgs.cs:line 79
   at Pipelines.Sockets.Unofficial.SocketConnection.DoReceiveAsync() in /_/src/Pipelines.Sockets.Unofficial/SocketConnection.Receive.cs:line 64
   --- End of inner exception stack trace ---
   at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result)
   at System.IO.Pipelines.Pipe.GetReadAsyncResult()
   at StackExchange.Redis.PhysicalConnection.ReadFromPipe() in /_/src/StackExchange.Redis/PhysicalConnection.cs:line 1760
   --- End of inner exception stack trace ---
   --- End of inner exception stack trace ---
   at Microsoft.AspNetCore.OutputCaching.StackExchangeRedis.RedisOutputCacheStore.Microsoft.AspNetCore.OutputCaching.IOutputCacheStore.GetAsync(String key, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.OutputCaching.OutputCacheEntryFormatter.GetAsync(String key, IOutputCacheStore store, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.OutputCaching.OutputCacheMiddleware.<>c.<<TryServeFromCacheAsync>b__14_0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.OutputCaching.WorkDispatcher`2.ScheduleAsync[TState](TKey key, TState state, Func`3 valueFactory)
   at Microsoft.AspNetCore.OutputCaching.OutputCacheMiddleware.TryServeFromCacheAsync(OutputCacheContext cacheContext, IReadOnlyList`1 policies)
AceHack commented 5 months ago

FYI, the reason I'm doing this is because I'm trying to run Visual Studio on my M2 Mac Studio on Windows ARM VM in Parallels and use Docker Desktop host on my Mac because I can't install docker desktop on Windows because I can't enable nested virtualization on Apple Silicon and therefore no Hyper-V and therefore no Docker Desktop on Windows ARM VM.

If there is a workaround to get this working, I'm happy to try another way.

AceHack commented 5 months ago

You can see I tried vscode on my Mac directly and it seems while I can run things, debugging does not appear to be working. https://github.com/dotnet/aspire/issues/1651

dbreshears commented 5 months ago

Not sure if we can get to this investigation in the near term to support Docker running on a remote host. I think that VS Code once it is supported will probably be the better solution for this.

giammin commented 1 month ago

Any news on this?

I run docker directly on wsl2 without using docker desktop and can't use aspire for this...

I see in the source that aspire look for docker desktop executable instead of referencing DOCKER_HOST environment variable as other libraries do (ex. testcontainer)

danegsta commented 1 month ago

We do depend on Docker CLI (or Podman CLI) being available on the path, but it doesn't have to specifically be Docker Desktop for Windows. Docker publishes builds of the Docker binaries or you can use a package manager such as winget or Chocolatey to install the Docker CLI.

giammin commented 1 month ago

Thanks for the hint, il give it a try. Just curious. there are any advantages or necessities to depend on the docker/podman cli instead of using the DOCKER_HOST solution?

giammin commented 1 month ago

i installed docker cli with winget and I can connect to the remote docker engine (my setup is docker engine running on wsl2 without docker desktop)

but aspire is still not working:

Microsoft.Extensions.Hosting.Internal.Host[11]
      Hosting failed to start
      Aspire.Hosting.DistributedApplicationException: Container runtime 'docker' could not be found. The error from the container runtime check was: exec: "docker": executable file not found in %PATH%.
      See https://aka.ms/dotnet/aspire/containers for more details on supported container runtimes.
         at Aspire.Hosting.Dcp.DcpDependencyCheck.EnsureDcpContainerRuntime(DcpInfo dcpInfo) in /_/src/Aspire.Hosting/Dcp/DcpDependencyCheck.cs:line 190
         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)

but the docker executable is in %PATH%.

pwsh  echo $Env:PATH C:\Program Files\PowerShell\7;C:\Program Files\Eclipse Adoptium\jdk-17.0.6.10-hotspot\bin;C:\Program Files\Python311\Scripts\;C:\Program Files\Python311\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Git\cmd;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\bin;C:\Program Files\WireGuard\;C:\Program Files\nodejs\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files\PowerShell\7\;C:\Users\giamm\AppData\Local\Microsoft\WindowsApps;C:\Users\giamm\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\giamm\AppData\Local\Programs\Azure Data Studio\bin;C:\Users\giamm.dotnet\tools;C:\Users\giamm\AppData\Local\Programs\oh-my-posh\bin;C:\Users\giamm\AppData\Roaming\npm;C:\Users\giamm\AppData\Local\Microsoft\WinGet\Packages\Docker.DockerCLI_Microsoft.Winget.Source_8wekyb3d8bbwe\docker;

danegsta commented 1 month ago

Thanks for the hint, il give it a try. Just curious. there are any advantages or necessities to depend on the docker/podman cli instead of using the DOCKER_HOST solution?

Mostly to avoid a lot of headaches with authentication/access to remote endpoints; the endpoint could be a named pipe, a unix domain socket, http(s), or even SSH, plus it (hopefully) is protected with certificates or other credentials, which would also need to be configured. Since Docker (or Podman) have already abstracted away all those connection details for us, it ends up easier to depend on the CLI (plus it has the added bonus of guaranteeing that any commands we run, the user can run the same command from the CLI and get the same results).

As for not finding docker on the path, first troubleshooting step I'd do would be to restart any VS/VSCode/shell instances that were running before you installed the CLI, since they wouldn't be able to see any changes to environment variables made after they were launched.

jiimaho commented 1 month ago

I get the same error as giammin above related to docker: Aspire.Hosting.DistributedApplicationException: Container runtime 'docker' could not be found. The error from the container runtime check was: exec: "docker": executable file not found in %PATH%.

Tried restart everything but still same error. When typing docker in a normal shell it works, so it's in my PATH. Feels like Rider, or more specifically something related to just Aspire gets the wrong PATH.

giammin commented 1 month ago

in my case after updating all the aspire requirements and a reboot the issue disappeared.