Docker image doesn't start when using WithDataVolume + WithDataBindMount
- 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
When combining `WithDataVolume` and `WithDataBindMount` the docker image fails to start.
## works
```
builder.AddRedis("redis").WithDataBindMount("/tmp/redis");
```
## works
```
builder.AddRedis("redis").WithDataVolume();
```
## fails
```
builder.AddRedis("redis").WithDataVolume().WithDataBindMount("/tmp/redis");
```
After `dotnet run`:
> fail: Aspire.Hosting.Dcp.dcpctrl.ContainerReconciler[0]
could not create the container {"Container": {"name":"redis-xubzakyt"}, "Reconciliation": 3, "error": "object not found\ncontainer not found\ndocker command 'CreateContainer' returned with non-zero exit code 1: command output: Stdout: '' Stderr: ''"}
Verified also with Qdrant extension.
Might be related to https://github.com/dotnet/aspire/issues/5378
### Expected Behavior
If `WithDataVolume` and `WithDataBindMount` are not supposed to work together, the app host should throw an exception at start.
### Steps To Reproduce
```
dotnet new create aspire-starter
cd test.AppHost
dotnet add package Aspire.Hosting.Redis
dotnet add package Aspire.Hosting.Qdrant
```
Update to 9.1 (the template is still on 9.0)
edit AppHost/Program.cs code:
```csharp
var builder = DistributedApplication.CreateBuilder(args);
var apiService = builder.AddProject("apiservice");
builder.AddProject("webfrontend")
.WithExternalHttpEndpoints()
.WithReference(apiService)
.WaitFor(apiService);
builder.AddRedis("redis")
.WithDataVolume()
.WithDataBindMount("/tmp/redis");
builder.Build().Run();
```
csproj:
```xml
Exe
net9.0
enable
enable
true
458c338e-0554-4812-a61a-d2c565e9f9b4
```
### Exceptions (if any)
Error in the logs:
> fail: Aspire.Hosting.Dcp.dcpctrl.ContainerReconciler[0]
> could not create the container {"Container": {"name":"redis-xgmwqqpg"}, "Reconciliation": 3, "error": "object not found\ncontainer not > found\ndocker command 'CreateContainer' returned with non-zero exit code 1: command output: Stdout: '' Stderr: ''"}
### .NET Version info
## .NET SDK:
Version: 9.0.200
Commit: 90e8b202f2
Workload version: 9.0.200-manifests.9bf19d2d
MSBuild version: 17.13.8+cbc39bea8
Runtime Environment:
OS Name: Mac OS X
OS Version: 15.3
OS Platform: Darwin
RID: osx-arm64
Base Path: /usr/local/share/dotnet/sdk/9.0.200/
## Docker
Client:
Version: 27.5.1
API version: 1.47
Go version: go1.22.11
Git commit: 9f9e405
Built: Wed Jan 22 13:37:19 2025
OS/Arch: darwin/arm64
Context: desktop-linux
Server: Docker Desktop 4.38.0 (181591)
Engine:
Version: 27.5.1
### Anything else?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.