Skip to content
Docs Try Aspire

DockerComposeServiceExtensions Methods

Class Methods 4 members
Provides extension methods for customizing Docker Compose service resources.
AsEnvironmentPlaceholder(IManifestExpressionProvider, DockerComposeServiceResource) Section titled AsEnvironmentPlaceholder(IManifestExpressionProvider, DockerComposeServiceResource) extension string
Creates a placeholder for an environment variable in the Docker Compose file.
public static class DockerComposeServiceExtensions
{
public static string AsEnvironmentPlaceholder(
this IManifestExpressionProvider manifestExpressionProvider,
DockerComposeServiceResource dockerComposeService)
{
// ...
}
}
manifestExpressionProvider IManifestExpressionProvider The manifest expression provider.
dockerComposeService DockerComposeServiceResource The Docker Compose service resource to associate the environment variable with.
string A string representing the environment variable placeholder in Docker Compose syntax (e.g., ${ENV_VAR}).
AsEnvironmentPlaceholder(IResourceBuilder<ParameterResource>, DockerComposeServiceResource) Section titled AsEnvironmentPlaceholder(IResourceBuilder<ParameterResource>, DockerComposeServiceResource) extension string
Creates a Docker Compose environment variable placeholder for the specified ApplicationModel.ParameterResource.
public static class DockerComposeServiceExtensions
{
public static string AsEnvironmentPlaceholder(
this IResourceBuilder<ParameterResource> builder,
DockerComposeServiceResource dockerComposeService)
{
// ...
}
}
builder IResourceBuilder<ParameterResource> The resource builder for the parameter resource.
dockerComposeService DockerComposeServiceResource The Docker Compose service resource to associate the environment variable with.
string A string representing the environment variable placeholder in Docker Compose syntax (e.g., ${ENV_VAR}).
AsEnvironmentPlaceholder(ParameterResource, DockerComposeServiceResource) Section titled AsEnvironmentPlaceholder(ParameterResource, DockerComposeServiceResource) extension string
Creates a Docker Compose environment variable placeholder for this ApplicationModel.ParameterResource.
public static class DockerComposeServiceExtensions
{
public static string AsEnvironmentPlaceholder(
this ParameterResource parameter,
DockerComposeServiceResource dockerComposeService)
{
// ...
}
}
parameter ParameterResource The parameter resource for which to create the environment variable placeholder.
dockerComposeService DockerComposeServiceResource The Docker Compose service resource to associate the environment variable with.
string A string representing the environment variable placeholder in Docker Compose syntax (e.g., ${ENV_VAR}).
PublishAsDockerComposeService(IResourceBuilder<T>, Action<DockerComposeServiceResource, Service>) Section titled PublishAsDockerComposeService(IResourceBuilder<T>, Action<DockerComposeServiceResource, Service>) extension IResourceBuilder<T>
Publishes the specified resource as a Docker Compose service.
public static class DockerComposeServiceExtensions
{
public static IResourceBuilder<T> PublishAsDockerComposeService<T>(
this IResourceBuilder<T> builder,
Action<DockerComposeServiceResource, Service> configure)
{
// ...
}
}
builder IResourceBuilder<T> The resource builder.
configure Action<DockerComposeServiceResource, Service> The configuration action for the Docker Compose service.
IResourceBuilder<T> The updated resource builder.
This method checks if the application is in publish mode. If it is, it adds a customization annotation that will be applied by the DockerComposeInfrastructure when generating the Docker Compose service.
builder.AddContainer(
"redis",
"redis:alpine").PublishAsDockerComposeService((resource, service) =>
{
service.Name = "redis";
});