Skip to content
DocsTry Aspire
DocsTry

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
methodpublishAsContainerbuilder
Changes the resource to be published as a container in the manifest.
publishAsContainer(): ContainerResource
ContainerResource
methodwithBindMountbuilder
Adds a bind mount to a container resource.
withBindMount(
source: string,
target: string,
isReadOnly?: boolean): ContainerResource
sourcestring
targetstring
isReadOnlybooleanoptional= False
ContainerResource
methodwithBuildArgbuilder
Adds a build argument when the container is built from a Dockerfile.
withBuildArg(
name: string,
value: ParameterResource): ContainerResource
namestring
valueParameterResource
ContainerResource
methodwithBuildSecretbuilder
Adds a secret build argument when the container is built from a Dockerfile.
withBuildSecret(
name: string,
value: ParameterResource): ContainerResource
namestring
valueParameterResource
ContainerResource
Adds container certificate path overrides used for certificate trust at run time.
withContainerCertificatePaths(
customCertificatesDestination?: string,
defaultCertificateBundlePaths?: string[],
defaultCertificateDirectoryPaths?: string[]): ContainerResource
customCertificatesDestinationstringoptional
defaultCertificateBundlePathsstring[]optional
defaultCertificateDirectoryPathsstring[]optional
ContainerResource
methodwithContainerNamebuilder
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
namestring
ContainerResource
Adds a network alias to container resource.
withContainerNetworkAlias(alias: string): ContainerResource
aliasstring
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
argsstring[]
ContainerResource
methodwithDockerfilebuilder
Causes Aspire to build the specified container image from a Dockerfile.
withDockerfile(
contextPath: string,
dockerfilePath?: string,
stage?: string): ContainerResource
contextPathstring
dockerfilePathstringoptional
stagestringoptional
ContainerResource
Configures the resource to use a programmatically generated Dockerfile
withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise<void>, stage?: string): ContainerResource
contextPathstring
callback(arg: DockerfileBuilderCallbackContext) => Promise<void>
stagestringoptional
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
contextPathstring
dockerfileFactory(arg: DockerfileFactoryContext) => Promise<string>
stagestringoptional
ContainerResource
methodwithEntrypointbuilder
Sets the Entrypoint for the container.
withEntrypoint(entrypoint: string): ContainerResource
entrypointstring
ContainerResource
methodwithImagebuilder
Allows overriding the image on a container.
withImage(
image: string,
tag?: string): ContainerResource
imagestring
tagstringoptional
ContainerResource
methodwithImagePullPolicybuilder
Sets the pull policy for the container resource.
withImagePullPolicy(pullPolicy: ImagePullPolicy): ContainerResource
pullPolicyImagePullPolicy
ContainerResource
methodwithImageRegistrybuilder
Allows overriding the image registry on a container.
withImageRegistry(registry: string): ContainerResource
registrystring
ContainerResource
methodwithImageSHA256builder
Allows setting the image to a specific sha256 on a container.
withImageSHA256(sha256: string): ContainerResource
sha256string
ContainerResource
methodwithImageTagbuilder
Allows overriding the image tag on a container.
withImageTag(tag: string): ContainerResource
tagstring
ContainerResource
methodwithLifetimebuilder
Sets the lifetime behavior of the container resource.
withLifetime(lifetime: ContainerLifetime): ContainerResource
lifetimeContainerLifetime
ContainerResource
methodwithVolumebuilder
Adds a volume to a container resource.
withVolume(
target: string,
name?: string,
isReadOnly?: boolean): ContainerResource
targetstring
namestringoptional
isReadOnlybooleanoptional= False
ContainerResource