Skip to content
Docs Try Aspire

ContainerResourceBuilderExtensions

Class static net8.0
📦 Aspire.Hosting v13.2.0
Provides extension methods for IDistributedApplicationBuilder to add container resources to the application.
namespace Aspire.Hosting;
public static class ContainerResourceBuilderExtensions
{
// ...
}
AddContainer(IDistributedApplicationBuilder, string, string)extensionats export
IResourceBuilder<ContainerResource>
Adds a container resource to the application. Uses the "latest" tag.
AddContainer(IDistributedApplicationBuilder, string, string, string)extensionats ignored
IResourceBuilder<ContainerResource>
Adds a container resource to the application.
AddDockerfile(IDistributedApplicationBuilder, string, string, string?, string?)extensionats export
IResourceBuilder<ContainerResource>
Adds a Dockerfile to the application model that can be treated like a container resource.
AddDockerfileBuilder(IDistributedApplicationBuilder, string, string, Func<DockerfileBuilderCallbackContext, Task>, string?)extensionexperimentalats ignored
IResourceBuilder<ContainerResource>
AddDockerfileBuilder(IDistributedApplicationBuilder, string, string, Action<DockerfileBuilderCallbackContext>, string?)extensionexperimentalats ignored
IResourceBuilder<ContainerResource>
AddDockerfileFactory(IDistributedApplicationBuilder, string, string, Func<DockerfileFactoryContext, string>, string?)extensionats ignored
IResourceBuilder<ContainerResource>
Adds a Dockerfile to the application model that can be treated like a container resource, with the Dockerfile content generated by a synchronous factory function.
AddDockerfileFactory(IDistributedApplicationBuilder, string, string, Func<DockerfileFactoryContext, Task<string>>, string?)extensionats ignored
IResourceBuilder<ContainerResource>
Adds a Dockerfile to the application model that can be treated like a container resource, with the Dockerfile content generated by an asynchronous factory function.
PublishAsContainer(IResourceBuilder<T>)extensionats export
Changes the resource to be published as a container in the manifest.
WithBindMount(IResourceBuilder<T>, string, string, bool)extensionats export
Adds a bind mount to a container resource.
WithBuildArg(IResourceBuilder<T>, string, object?)extensionats ignored
Adds a build argument when the container is build from a Dockerfile.
WithBuildArg(IResourceBuilder<T>, string, IResourceBuilder<ParameterResource>)extensionats export
Adds a build argument when the container is built from a Dockerfile.
WithBuildSecret(IResourceBuilder<T>, string, IResourceBuilder<ParameterResource>)extensionats export
Adds a secret build argument when the container is built from a Dockerfile.
WithContainerCertificatePaths(IResourceBuilder<TResource>, string?, List<string>, List<string>)extensionats ignored
IResourceBuilder<TResource>
Adds a ContainerCertificatePathsAnnotation to the resource that allows overriding the default paths in the container used for certificate trust. Custom certificate trust is only supported at run time.
WithContainerFiles(IResourceBuilder<T>, string, IEnumerable<ContainerFileSystemItem>, int?, int?, UnixFileMode?)extensionats ignored
Creates or updates files and/or folders at the destination path in the container.
WithContainerFiles(IResourceBuilder<T>, string, Func<ContainerFileSystemCallbackContext, CancellationToken, Task<IEnumerable<ContainerFileSystemItem>>>, int?, int?, UnixFileMode?)extensionats ignored
Creates or updates files and/or folders at the destination path in the container. Receives a callback that will be invoked when the container is started to allow the files to be created based on other resources in the application model.
WithContainerFiles(IResourceBuilder<T>, string, string, int?, int?, UnixFileMode?)extensionats ignored
Creates or updates files and/or folders at the destination path in the container by copying them from a source path on the host. In run mode, this will copy the files from the host to the container at runtime, allowing for overriding ownership and permissions in the container. In publish mode, this will create a bind mount to the source path on the host.
WithContainerName(IResourceBuilder<T>, string)extensionats export
Overrides the default container name for this resource. By default Aspire generates a unique container name based on the resource name and a random postfix (or a postfix based on a hash of the AppHost project path for persistent container resources). This method allows you to override that behavior with a custom name, but could lead to naming conflicts if the specified name is not unique.
WithContainerNetworkAlias(IResourceBuilder<T>, string)extensionats export
Adds a network alias to container resource.
WithContainerRuntimeArgs(IResourceBuilder<T>, string[])extensionats export
Adds a callback to be executed with a list of arguments to add to the container runtime run command when a container resource is started.
WithContainerRuntimeArgs(IResourceBuilder<T>, Action<ContainerRuntimeArgsCallbackContext>)extensionats ignored
Adds a callback to be executed with a list of arguments to add to the container runtime run command when a container resource is started.
WithContainerRuntimeArgs(IResourceBuilder<T>, Func<ContainerRuntimeArgsCallbackContext, Task>)extensionats ignored
Adds a callback to be executed with a list of arguments to add to the container runtime run command when a container resource is started.
WithDockerfile(IResourceBuilder<T>, string, string?, string?)extensionats export
Causes Aspire to build the specified container image from a Dockerfile.
WithDockerfileBaseImage(IResourceBuilder<T>, string?, string?)extensionexperimentalats export
Configures custom base images for generated Dockerfiles.
WithDockerfileBuilder(IResourceBuilder<T>, string, Func<DockerfileBuilderCallbackContext, Task>, string?)extensionexperimentalats ignored
Builds the specified container image from a Dockerfile generated by a callback using the DockerfileBuilder API.
WithDockerfileBuilder(IResourceBuilder<T>, string, Action<DockerfileBuilderCallbackContext>, string?)extensionexperimentalats ignored
Builds the specified container image from a Dockerfile generated by a synchronous callback using the DockerfileBuilder API.
WithDockerfileFactory(IResourceBuilder<T>, string, Func<DockerfileFactoryContext, string>, string?)extensionats ignored
Builds the specified container image from a Dockerfile generated by a synchronous factory function.
WithDockerfileFactory(IResourceBuilder<T>, string, Func<DockerfileFactoryContext, Task<string>>, string?)extensionats ignored
Builds the specified container image from a Dockerfile generated by an asynchronous factory function.
WithEndpointProxySupport(IResourceBuilder<T>, bool)extensionats export
Set whether a container resource can use proxied endpoints or whether they should be disabled for all endpoints belonging to the container. If set to false, endpoints belonging to the container resource will ignore the configured proxy settings and run proxy-less.
WithEntrypoint(IResourceBuilder<T>, string)extensionats export
Sets the Entrypoint for the container.
WithImage(IResourceBuilder<T>, string, string?)extensionats export
Allows overriding the image on a container.
WithImagePullPolicy(IResourceBuilder<T>, ImagePullPolicy)extensionats export
Sets the pull policy for the container resource.
WithImageRegistry(IResourceBuilder<T>, string?)extensionats export
Allows overriding the image registry on a container.
WithImageSHA256(IResourceBuilder<T>, string)extensionats export
Allows setting the image to a specific sha256 on a container.
WithImageTag(IResourceBuilder<T>, string)extensionats export
Allows overriding the image tag on a container.
WithLifetime(IResourceBuilder<T>, ContainerLifetime)extensionats export
Sets the lifetime behavior of the container resource.
WithVolume(IResourceBuilder<T>, string?, string, bool)extensionats ignored
Adds a volume to a container resource.
WithVolume(IResourceBuilder<T>, string)extensionats ignored
Adds an anonymous volume to a container resource.
View all methods