Skip to content
Docs Try Aspire
Docs Try

ContainerResource

Handle
📦 Aspire.Hosting v13.4.0
interface ContainerResource
extends IComputeResource,
IResource,
IResourceWithArgs,
IResourceWithEndpoints,
IResourceWithEnvironment,
IResourceWithProbes,
IResourceWithWaitSupport {
publishAsConnectionString(): ContainerResource;
publishAsContainer(): ContainerResource;
withBindMount(
source: string,
target: string,
isReadOnly?: boolean): ContainerResource;
withBuildArg(
name: string,
value: ParameterResource): ContainerResource;
withBuildSecret(
name: string,
value: ParameterResource): ContainerResource;
withContainerCertificatePaths(
customCertificatesDestination?: string,
defaultCertificateBundlePaths?: string[],
defaultCertificateDirectoryPaths?: string[]): ContainerResource;
withContainerName(name: string): ContainerResource;
withContainerNetworkAlias(alias: string): ContainerResource;
withContainerRuntimeArgs(args: string[]): ContainerResource;
withDockerfile(
contextPath: string,
dockerfilePath?: string,
stage?: string): ContainerResource;
withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise<void>, stage?: string): ContainerResource;
withDockerfileFactory(contextPath: string, dockerfileFactory: (arg: DockerfileFactoryContext) => Promise<string>, stage?: string): ContainerResource;
withEntrypoint(entrypoint: string): ContainerResource;
withImage(
image: string,
tag?: string): ContainerResource;
withImagePullPolicy(pullPolicy: ImagePullPolicy): ContainerResource;
withImageRegistry(registry: string): ContainerResource;
withImageSHA256(sha256: string): ContainerResource;
withImageTag(tag: string): ContainerResource;
withLifetime(lifetime: ContainerLifetime): ContainerResource;
withVolume(
target: string,
name?: string,
isReadOnly?: boolean): ContainerResource;
}

Methods

Changes the resource to be published as a connection string reference in the manifest.
publishAsConnectionString(): ContainerResource
ContainerResource
method publishAsContainer builder
Changes the resource to be published as a container in the manifest.
publishAsContainer(): ContainerResource
ContainerResource
method withBindMount builder
Adds a bind mount to a container resource.
withBindMount(
source: string,
target: string,
isReadOnly?: boolean): ContainerResource
source string
target string
isReadOnly boolean optional = False
ContainerResource
method withBuildArg builder
Adds a build argument when the container is built from a Dockerfile.
withBuildArg(
name: string,
value: ParameterResource): ContainerResource
name string
value ParameterResource
ContainerResource
method withBuildSecret builder
Adds a secret build argument when the container is built from a Dockerfile.
withBuildSecret(
name: string,
value: ParameterResource): ContainerResource
name string
value ParameterResource
ContainerResource
Adds container certificate path overrides used for certificate trust at run time.
withContainerCertificatePaths(
customCertificatesDestination?: string,
defaultCertificateBundlePaths?: string[],
defaultCertificateDirectoryPaths?: string[]): ContainerResource
customCertificatesDestination string optional
defaultCertificateBundlePaths string[] optional
defaultCertificateDirectoryPaths string[] optional
ContainerResource
method withContainerName builder
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.
withContainerName(name: string): ContainerResource
name string
ContainerResource
Adds a network alias to container resource.
withContainerNetworkAlias(alias: string): ContainerResource
alias string
ContainerResource
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(args: string[]): ContainerResource
args string[]
ContainerResource
method withDockerfile builder
Causes Aspire to build the specified container image from a Dockerfile.
withDockerfile(
contextPath: string,
dockerfilePath?: string,
stage?: string): ContainerResource
contextPath string
dockerfilePath string optional
stage string optional
ContainerResource
Configures the resource to use a programmatically generated Dockerfile
withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise<void>, stage?: string): ContainerResource
contextPath string
callback (arg: DockerfileBuilderCallbackContext) => Promise<void>
stage string optional
ContainerResource
Builds the specified container image from a Dockerfile generated by an asynchronous factory function.
withDockerfileFactory(contextPath: string, dockerfileFactory: (arg: DockerfileFactoryContext) => Promise<string>, stage?: string): ContainerResource
contextPath string
dockerfileFactory (arg: DockerfileFactoryContext) => Promise<string>
stage string optional
ContainerResource
method withEntrypoint builder
Sets the Entrypoint for the container.
withEntrypoint(entrypoint: string): ContainerResource
entrypoint string
ContainerResource
method withImage builder
Allows overriding the image on a container.
withImage(
image: string,
tag?: string): ContainerResource
image string
tag string optional
ContainerResource
method withImagePullPolicy builder
Sets the pull policy for the container resource.
withImagePullPolicy(pullPolicy: ImagePullPolicy): ContainerResource
pullPolicy ImagePullPolicy
ContainerResource
method withImageRegistry builder
Allows overriding the image registry on a container.
withImageRegistry(registry: string): ContainerResource
registry string
ContainerResource
method withImageSHA256 builder
Allows setting the image to a specific sha256 on a container.
withImageSHA256(sha256: string): ContainerResource
sha256 string
ContainerResource
method withImageTag builder
Allows overriding the image tag on a container.
withImageTag(tag: string): ContainerResource
tag string
ContainerResource
method withLifetime builder
Sets the lifetime behavior of the container resource.
withLifetime(lifetime: ContainerLifetime): ContainerResource
lifetime ContainerLifetime
ContainerResource
method withVolume builder
Adds a volume to a container resource.
withVolume(
target: string,
name?: string,
isReadOnly?: boolean): ContainerResource
target string
name string optional
isReadOnly boolean optional = False
ContainerResource