# withLifetime

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

Sets the lifetime behavior of the container resource

## Definition

```typescript
interface ContainerResource {
  // ... omitted for brevity
  withLifetime(lifetime: ContainerLifetime): ContainerResource
}
```

## Parameters

- `lifetime` ([ContainerLifetime](/reference/api/typescript/aspire.hosting/containerlifetime.md))

## Returns

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

## Applies to

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