# ContainerResource

- Module: [Aspire.Hosting](/reference/api/typescript/aspire.hosting.md)
- Version: `13.2.0`
- Kind: `handle`
- Source: [GitHub](https://github.com/microsoft/aspire)

## Definition

```typescript
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;
  withContainerName(name: string): ContainerResource;
  withContainerNetworkAlias(alias: string): ContainerResource;
  withContainerRuntimeArgs(args: string[]): ContainerResource;
  withDockerfile(
      contextPath: string,
      dockerfilePath?: string,
      stage?: string): ContainerResource;
  withEndpointProxySupport(proxyEnabled: boolean): 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

- [publishAsConnectionString](/reference/api/typescript/aspire.hosting/containerresource/publishasconnectionstring.md) -- `method` -- Publishes the resource as a connection string
    ```typescript
  publishAsConnectionString(): ContainerResource
  ```
- [publishAsContainer](/reference/api/typescript/aspire.hosting/containerresource/publishascontainer.md) -- `method` -- Configures the resource to be published as a container
    ```typescript
  publishAsContainer(): ContainerResource
  ```
- [withBindMount](/reference/api/typescript/aspire.hosting/containerresource/withbindmount.md) -- `method` -- Adds a bind mount
    ```typescript
  withBindMount(source: string, target: string, isReadOnly?: boolean): ContainerResource
  ```
- [withBuildArg](/reference/api/typescript/aspire.hosting/containerresource/withbuildarg.md) -- `method` -- Adds a build argument from a parameter resource
    ```typescript
  withBuildArg(name: string, value: ParameterResource): ContainerResource
  ```
- [withBuildSecret](/reference/api/typescript/aspire.hosting/containerresource/withbuildsecret.md) -- `method` -- Adds a build secret from a parameter resource
    ```typescript
  withBuildSecret(name: string, value: ParameterResource): ContainerResource
  ```
- [withContainerName](/reference/api/typescript/aspire.hosting/containerresource/withcontainername.md) -- `method` -- Sets the container name
    ```typescript
  withContainerName(name: string): ContainerResource
  ```
- [withContainerNetworkAlias](/reference/api/typescript/aspire.hosting/containerresource/withcontainernetworkalias.md) -- `method` -- Adds a network alias for the container
    ```typescript
  withContainerNetworkAlias(alias: string): ContainerResource
  ```
- [withContainerRuntimeArgs](/reference/api/typescript/aspire.hosting/containerresource/withcontainerruntimeargs.md) -- `method` -- Adds runtime arguments for the container
    ```typescript
  withContainerRuntimeArgs(args: string[]): ContainerResource
  ```
- [withDockerfile](/reference/api/typescript/aspire.hosting/containerresource/withdockerfile.md) -- `method` -- Configures the resource to use a Dockerfile
    ```typescript
  withDockerfile(contextPath: string, dockerfilePath?: string, stage?: string): ContainerResource
  ```
- [withEndpointProxySupport](/reference/api/typescript/aspire.hosting/containerresource/withendpointproxysupport.md) -- `method` -- Configures endpoint proxy support
    ```typescript
  withEndpointProxySupport(proxyEnabled: boolean): ContainerResource
  ```
- [withEntrypoint](/reference/api/typescript/aspire.hosting/containerresource/withentrypoint.md) -- `method` -- Sets the container entrypoint
    ```typescript
  withEntrypoint(entrypoint: string): ContainerResource
  ```
- [withImage](/reference/api/typescript/aspire.hosting/containerresource/withimage.md) -- `method` -- Sets the container image
    ```typescript
  withImage(image: string, tag?: string): ContainerResource
  ```
- [withImagePullPolicy](/reference/api/typescript/aspire.hosting/containerresource/withimagepullpolicy.md) -- `method` -- Sets the container image pull policy
    ```typescript
  withImagePullPolicy(pullPolicy: ImagePullPolicy): ContainerResource
  ```
- [withImageRegistry](/reference/api/typescript/aspire.hosting/containerresource/withimageregistry.md) -- `method` -- Sets the container image registry
    ```typescript
  withImageRegistry(registry: string): ContainerResource
  ```
- [withImageSHA256](/reference/api/typescript/aspire.hosting/containerresource/withimagesha256.md) -- `method` -- Sets the image SHA256 digest
    ```typescript
  withImageSHA256(sha256: string): ContainerResource
  ```
- [withImageTag](/reference/api/typescript/aspire.hosting/containerresource/withimagetag.md) -- `method` -- Sets the container image tag
    ```typescript
  withImageTag(tag: string): ContainerResource
  ```
- [withLifetime](/reference/api/typescript/aspire.hosting/containerresource/withlifetime.md) -- `method` -- Sets the lifetime behavior of the container resource
    ```typescript
  withLifetime(lifetime: ContainerLifetime): ContainerResource
  ```
- [withVolume](/reference/api/typescript/aspire.hosting/containerresource/withvolume.md) -- `method` -- Adds a volume
    ```typescript
  withVolume(target: string, name?: string, isReadOnly?: boolean): ContainerResource
  ```
