ContainerResource
Handle
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: string | ParameterResource): ContainerResource; withBuildSecret( name: string, value: ParameterResource): ContainerResource; withContainerCertificatePaths( customCertificatesDestination?: string, defaultCertificateBundlePaths?: string[], defaultCertificateDirectoryPaths?: string[]): ContainerResource; withContainerFiles( destinationPath: string, sourcePath: string, options?: ContainerFilesOptions): ContainerResource; withContainerFilesCallback(destinationPath: string, callback: (arg1: ContainerFileSystemCallbackContext, arg2: cancellationToken) => Promise<ContainerFileSystemItem[]>, options?: ContainerFilesOptions): 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;}22 members
Methods
Changes the resource to be published as a connection string reference in the manifest.
publishAsConnectionString(): ContainerResourceReturns
ContainerResource Changes the resource to be published as a container in the manifest.
publishAsContainer(): ContainerResourceReturns
ContainerResource Adds a bind mount to a container resource.
withBindMount( source: string, target: string, isReadOnly?: boolean): ContainerResourceParameters
sourcestringThe source path of the mount. This is the path to the file or directory on the host, relative to the AppHost project directory.targetstringThe target path where the file or directory is mounted in the container.isReadOnly booleanoptional= FalseA flag that indicates if this is a read-only mount.Returns
ContainerResource Adds a build argument when the container is built from a Dockerfile.
withBuildArg( name: string, value: string | ParameterResource): ContainerResourceParameters
namestringThe name of the build argument.valuestring | ParameterResource The build argument value, either a string or a parameter resource.Returns
ContainerResource Adds a secret build argument when the container is built from a Dockerfile.
withBuildSecret( name: string, value: ParameterResource): ContainerResourceParameters
namestringThe name of the secret build argument.valueParameterResource The resource builder for a parameter resource.Returns
ContainerResource Adds container certificate path overrides used for certificate trust at run time.
withContainerCertificatePaths( customCertificatesDestination?: string, defaultCertificateBundlePaths?: string[], defaultCertificateDirectoryPaths?: string[]): ContainerResourceParameters
customCertificatesDestination stringoptionalThe destination path in the container where custom certificates will be copied.defaultCertificateBundlePaths string[]optionalDefault certificate bundle paths in the container that will be replaced.defaultCertificateDirectoryPaths string[]optionalDefault certificate directory paths in the container that may be appended.Returns
ContainerResource Creates or updates files and folders in a container by copying them from a source path on the host.
withContainerFiles( destinationPath: string, sourcePath: string, options?: ContainerFilesOptions): ContainerResourceParameters
destinationPath stringThe destination absolute path in the container.sourcePath stringThe source path on the host to copy files from.optionsContainerFilesOptions optionalOptions for the created or updated file system entries.Returns
ContainerResource Creates or updates files and/or folders at the destination path in the container using entries produced by a callback.
withContainerFilesCallback(destinationPath: string, callback: (arg1: ContainerFileSystemCallbackContext, arg2: cancellationToken) => Promise<ContainerFileSystemItem[]>, options?: ContainerFilesOptions): ContainerResourceParameters
destinationPath stringThe destination absolute path in the container.callback(arg1: ContainerFileSystemCallbackContext, arg2: cancellationToken) => Promise<ContainerFileSystemItem[]> A callback that returns the file system entries to create or update. Use the factory methods on `ContainerFileSystemCallbackContext` (createFile, createDirectory, createCertificateFile) to build the entries.optionsContainerFilesOptions optionalOptions for the created or updated file system entries.Returns
ContainerResource 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): ContainerResourceParameters
namestringThe desired container name. Must be a valid container name or your runtime will report an error.Returns
ContainerResource Adds a network alias to container resource.
withContainerNetworkAlias(alias: string): ContainerResourceParameters
aliasstringThe network alias for the container.Returns
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[]): ContainerResourceParameters
argsstring[]The arguments to be passed to the container runtime run command when the container resource is started.Returns
ContainerResource Causes Aspire to build the specified container image from a Dockerfile.
withDockerfile( contextPath: string, dockerfilePath?: string, stage?: string): ContainerResourceParameters
contextPath stringPath to be used as the context for the container image build.dockerfilePath stringoptionalPath to the Dockerfile relative to the `contextPath`. Defaults to "Dockerfile" if not specified.stagestringoptionalThe stage representing the image to be published in a multi-stage Dockerfile.Returns
ContainerResource Configures the resource to use a programmatically generated Dockerfile
withDockerfileBuilder(contextPath: string, callback: (arg: DockerfileBuilderCallbackContext) => Promise<void>, stage?: string): ContainerResourceParameters
contextPath stringPath to be used as the context for the container image build.callback(arg: DockerfileBuilderCallbackContext) => Promise<void> A callback that uses the `DockerfileBuilder` API to construct the Dockerfile.stagestringoptionalThe stage representing the image to be published in a multi-stage Dockerfile.Returns
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): ContainerResourceParameters
contextPath stringPath to be used as the context for the container image build.dockerfileFactory (arg: DockerfileFactoryContext) => Promise<string> An asynchronous function that returns the Dockerfile content as a string.stagestringoptionalThe stage representing the image to be published in a multi-stage Dockerfile.Returns
ContainerResource Sets the Entrypoint for the container.
withEntrypoint(entrypoint: string): ContainerResourceParameters
entrypointstringThe new entrypoint for the container.Returns
ContainerResource Allows overriding the image on a container.
withImage( image: string, tag?: string): ContainerResourceParameters
imagestringImage value.tagstringoptionalTag value.Returns
ContainerResource Sets the pull policy for the container resource.
withImagePullPolicy(pullPolicy: ImagePullPolicy): ContainerResourceParameters
pullPolicy ImagePullPolicy The pull policy behavior for the container resource.Returns
ContainerResource Allows overriding the image registry on a container.
withImageRegistry(registry: string): ContainerResourceParameters
registrystringRegistry value.Returns
ContainerResource Allows setting the image to a specific sha256 on a container.
withImageSHA256(sha256: string): ContainerResourceParameters
sha256stringRegistry value.Returns
ContainerResource Allows overriding the image tag on a container.
withImageTag(tag: string): ContainerResourceParameters
tagstringTag value.Returns
ContainerResource Sets the lifetime behavior of the container resource.
withLifetime(lifetime: ContainerLifetime): ContainerResourceParameters
lifetimeContainerLifetime The lifetime behavior of the container resource. The default behavior is `Session`.Returns
ContainerResource Adds a volume to a container resource.
withVolume( target: string, name?: string, isReadOnly?: boolean): ContainerResourceParameters
targetstringThe mount path inside the container.namestringoptionalThe volume name. If null, an anonymous volume is created.isReadOnly booleanoptional= FalseWhether the volume is read-only.Returns
ContainerResource