# 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](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.EcsVolume.html) › HostVolume
Obtainable from: [EcsVolume.host](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_batch.EcsVolume.html#host)

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

## Example

TypeScript:

```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,
});
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_batch as batch

host_volume = batch.HostVolume(
    container_path="containerPath",
    name="name",

    # the properties below are optional
    host_path="hostPath",
    readonly=False
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.batch.*;

HostVolume hostVolume = HostVolume.Builder.create()
        .containerPath("containerPath")
        .name("name")

        // the properties below are optional
        .hostPath("hostPath")
        .readonly(false)
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.Batch;

var hostVolume = new HostVolume(new HostVolumeOptions {
    ContainerPath = "containerPath",
    Name = "name",

    // the properties below are optional
    HostPath = "hostPath",
    Readonly = false
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

hostVolume := awscdk.Aws_batch.NewHostVolume(&HostVolumeOptions{
	ContainerPath: jsii.String("containerPath"),
	Name: jsii.String("name"),

	// the properties below are optional
	HostPath: jsii.String("hostPath"),
	Readonly: jsii.Boolean(false),
})
```

## Initializer

TypeScript:

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

Python:

```python
HostVolume(options: HostVolumeOptions)
```

Java:

```java
new HostVolume(HostVolumeOptions options)
```

C# / .NET:

```csharp
new HostVolume(HostVolumeOptions options)
```

Golang:

```go
NewHostVolume(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.
