docs-aspire
docs-aspire copied to clipboard
[New article]: Docs for new persistent container lifetime feature in 9.0
Proposed topic or title
Persistent container services
Location in table of contents.
App Host (Orchestration)
Reason for the article
Aspire 9.0 adds a new ContainerResourceBuilderExtensions.WithLifetime
API that can be used to mark a runtime container as persistent. This allows the container to be retained when the App Host is stopped and re-used on subsequent runs.
Article abstract
Learn to configure containers to persist and be re-used between App Host runs.
- This particularly benefits containers that have a long startup time such as databases
- Persistent containers may still be recreated on a subsequent run if the AppHost configuration changes meaningfully
- We use a label on containers to track a hash of the configuration used to create the container and compare it to the current configuration; if different we recreate the container
- Existing persistent containers are identified based on the container name
- By default persistent containers have a name that is a combination of the service name and a postfix based on a hash of the App Host project path, this means that a persistent container will be unique to a given AppHost project
- For advanced scenarios, a user can set a custom container name using the new
WithContainerName
API; this can allow Aspire to re-use a container that wasn't created by the AppHost (such a container will never be recreated)
Relevant searches
No response