-
I am able to use AddSqlContainer successfully in my AppHost project. The problem is that every time I stop AppHost, the container is destroyed (which is fine) but also all the data I had in the DB is destroyed with it. I'd like to have a way to specify a persistent volume that should survive beyond the lifetime of the AppHost and get reconnected on subsequent runs. For reference, this is my current setup: var builder = DistributedApplication.CreateBuilder(args);
var pass = builder.Configuration["SqlPassword"];
var sql = builder.AddSqlServerContainer("sql", pass, 1433)
.AddDatabase("GameStore");
var backend = builder.AddProject<Projects.GameStore_Api>("backend")
.WithReference(sql);
builder.AddProject<Projects.GameStore_Frontend>("frontend")
.WithReference(backend);
var app = builder.Build();
app.Run(); And this is how I run my SQL Server container manually today:
Also, I already tried using WithVolumeMount() but it makes no difference, the data is gone. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
I had similar issue with you. When I change VolumeMountType from Bind to Named, it solved. I think this is going to solve your problem. At least it worked for elasticsearch. Also, default VolumeMountType is Bind.
|
Beta Was this translation helpful? Give feedback.
-
There's an example with volume mounts here https://github.com/dotnet/aspire-samples/tree/main/samples/DatabaseContainers |
Beta Was this translation helpful? Give feedback.
There's an example with volume mounts here https://github.com/dotnet/aspire-samples/tree/main/samples/DatabaseContainers