Skip to content

Persistent mongodb container recreated on every run #11238

@voiladaniel

Description

@voiladaniel

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Currently, the MongoDB container is being recreated every time it is stopped, even though the same configuration is used each time.

Image

Expected Behavior

Only one persistent container created for any number of runs with the same configuration.

Steps To Reproduce

var mongo = builder.AddMongoDB("mongo", 27020)
.WithContainerName("mongo")
.WithEnvironment("MONGO_INITDB_DATABASE", "MyTestDB")
.WithEnvironment("MONGO_INITDB_ROOT_USERNAME", "user")
.WithEnvironment("MONGO_INITDB_ROOT_PASSWORD", "pass")
.WithDataVolume("mtmongodata")
.WithBindMount("./init-mongo.js", "/docker-entrypoint-initdb.d/mongo-init.js", isReadOnly: true)
.WithLifetime(ContainerLifetime.Persistent);

  1. Run the aspire project with this configuration
  2. After the projected started successfully, run docker stop <cotnainerid>
  3. Run again the aspire project with the same configuration.

Exceptions (if any)

No response

.NET Version info

.NET SDK:
Version: 9.0.304
Commit: f12f5f689e
Workload version: 9.0.300-manifests.610a1858
MSBuild version: 17.14.16+5d8159c5f

Runtime Environment:
OS Name: Windows
OS Version: 10.0.26100
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\9.0.304\

Anything else?

Project target framework: NET 9.0
Aspire.Hosting.AppHost version: 9.3.1
Aspire.Hosting.MongoDB version: 9.3.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-integrationsIssues pertaining to Aspire Integrations packagesmongodbIssues related to mongodb integrations

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions