# ContainerResource.withContainerName

- Module: [Aspire.Hosting](/reference/api/typescript/aspire.hosting.md)
- Defined on: [ContainerResource](/reference/api/typescript/aspire.hosting/containerresource.md)
- Version: `13.4.0`
- Kind: `method`

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.

## Definition

```typescript
interface ContainerResource {
  // ... omitted for brevity
  withContainerName(name: string): ContainerResource;
}
```

## Signature

```typescript
withContainerName(name: string): ContainerResource
```

## Parameters

- `name` (`string`)

## Returns

[ContainerResource](/reference/api/typescript/aspire.hosting/containerresource.md) `builder`

## Defined on

- [ContainerResource](/reference/api/typescript/aspire.hosting/containerresource.md) -- `handle`
