# HostVolume

Creates a Host volume.

This volume will persist on the host at the specified `hostPath`.
If the `hostPath` is not specified, Docker will choose the host path. In this case,
the data may not persist after the containers that use it stop running.

Extends: EcsVolume › HostVolume

- Source: [`aws-batch/lib/ecs-container-definition.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-batch/lib/ecs-container-definition.ts#L352)
- Type last changed: v2.96.0 · 13 Sep 2023

## Example

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_batch as batch } from 'aws-cdk-lib';
const hostVolume = new batch.HostVolume({
  containerPath: 'containerPath',
  name: 'name',

  // the properties below are optional
  hostPath: 'hostPath',
  readonly: false,
});
```

## Initializer

```ts
new HostVolume(options: HostVolumeOptions)
```

## Properties

- `containerPath`: string — The path on the container that this volume will be mounted to.

- `hostPath`: string — The path on the host machine this container will have access to.

- `name`: string — The name of this volume.

- `readonly`: boolean = false — Whether or not the container has readonly access to this volume.

## Methods

- `efs(options: EfsVolumeOptions): EfsVolume` (static) — Creates a Volume that uses an AWS Elastic File System (EFS);

  this volume can grow and shrink as needed

- `host(options: HostVolumeOptions): HostVolume // chainable` (static) — Creates a Host volume.

  This volume will persist on the host at the specified `hostPath`.
  If the `hostPath` is not specified, Docker will choose the host path. In this case,
  the data may not persist after the containers that use it stop running.

- `isHostVolume(x: any): boolean` (static) — returns `true` if `x` is a `HostVolume`, `false` otherwise.
