Container `WithExplicitStart()` fails `StartAsync` when container runtime is unavaialble - even if it's never started.
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 196
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Describe the bug
If the only containers in your app host are `WithExplicitStart()`, then `app.StartAsync` block if docker is not running.
### Expected Behavior
Since the container is being explicitly started, and there are no other containers in the app host, the container runtime being unavailable should not block `StartAsync`.
### Steps To Reproduce
```
[Fact]
public async Task StartAsyncWithExplicitStartContainer()
{
var cts = CancellationTokenSource.CreateLinkedTokenSource(TestContext.Current.CancellationToken);
await using var builder = DistributedApplicationTestingBuilder.Create();
var manual = builder.AddContainer("nginx", "nginx")
.WithExplicitStart();
await using var app = builder.Build();
await app.StartAsync(cts.Token);
}
```
### Exceptions (if any)
```
AppHostPerTest.Scenarios.StartAsyncWithExplicitStartContainer
Source: Scenarios.cs line 10
Duration: 40.4 sec
Message:
Aspire.Hosting.DistributedApplicationException : Container runtime 'docker' was found but appears to be unhealthy. Ensure that Docker is running and that the Docker daemon is accessible. If Resource Saver mode is enabled, containers may not run.
Stack Trace:
DcpDependencyCheck.CheckDcpInfoAndLogErrors(ILogger logger, DcpOptions options, DcpInfo dcpInfo, Boolean throwIfUnhealthy)
DcpHost.EnsureDcpContainerRuntimeAsync(CancellationToken cancellationToken)
DcpHost.StartAsync(CancellationToken cancellationToken)
OrchestratorHostService.StartAsync(CancellationToken cancellationToken)
Host.b__14_1(IHostedService service, CancellationToken token)
Host.ForeachService[T](IEnumerable`1 services, CancellationToken token, Boolean concurrent, Boolean abortOnFirstException, List`1 exceptions, Func`3 operation)
Host.StartAsync(CancellationToken cancellationToken)
DistributedApplication.StartAsync(CancellationToken cancellationToken)
Scenarios.StartAsyncWithExplicitStartContainer() line 18
Scenarios.StartAsyncWithExplicitStartContainer() line 18
Scenarios.StartAsyncWithExplicitStartContainer() line 18
--- End of stack trace from previous location ---
Standard Output:
info: Aspire.Hosting.DistributedApplication[0]
Aspire version: 13.1.0+8a4db1775c3fbae1c602022b636299cb04971fde
info: Aspire.Hosting.DistributedApplication[0]
Distributed application starting.
info: Aspire.Hosting.DistributedApplication[0]
Application host directory is: S:\aspire-otel-testing\tests\AppHostPerTest
warn: Aspire.Hosting.Dcp.DcpHost[0]
Container runtime 'docker' was found but appears to be unhealthy. Ensure that Docker is running and that the Docker daemon is accessible. If Resource Saver mode is enabled, containers may not run. For more information, visit: https://docs.docker.com/desktop/use-desktop/resource-saver/
fail: Microsoft.Extensions.Hosting.Internal.Host[11]
Hosting failed to start
Aspire.Hosting.DistributedApplicationException: Container runtime 'docker' was found but appears to be unhealthy. Ensure that Docker is running and that the Docker daemon is accessible. If Resource Saver mode is enabled, containers may not run.
at Aspire.Hosting.Dcp.DcpDependencyCheck.CheckDcpInfoAndLogErrors(ILogger logger, DcpOptions options, DcpInfo dcpInfo, Boolean throwIfUnhealthy) in /_/src/Aspire.Hosting/Dcp/DcpDependencyCheck.cs:line 272
at Aspire.Hosting.Dcp.DcpHost.EnsureDcpContainerRuntimeAsync(CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Dcp/DcpHost.cs:line 113
at Aspire.Hosting.Dcp.DcpHost.StartAsync(CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Dcp/DcpHost.cs:line 65
at Aspire.Hosting.Orchestrator.OrchestratorHostService.StartAsync(CancellationToken cancellationToken) in /_/src/Aspire.Hosting/Orchestrator/OrchestratorHostService.cs:line 39
at Microsoft.Extensions.Hosting.Internal.Host.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)
```
### .NET Version info
_No response_
### Anything else?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.