# DockerVolumeConfiguration

The configuration for a Docker volume.

Docker volumes are only supported when you are using the EC2 launch type.

- Source: [`aws-ecs/lib/base/task-definition.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-ecs/lib/base/task-definition.ts#L1251)

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_ecs as ecs } from 'aws-cdk-lib';
const dockerVolumeConfiguration: ecs.DockerVolumeConfiguration = {
  driver: 'driver',
  scope: ecs.Scope.TASK,

  // the properties below are optional
  autoprovision: false,
  driverOpts: {
    driverOptsKey: 'driverOpts',
  },
  labels: {
    labelsKey: 'labels',
  },
};
```

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_ecs as ecs

docker_volume_configuration = ecs.DockerVolumeConfiguration(
    driver="driver",
    scope=ecs.Scope.TASK,

    # the properties below are optional
    autoprovision=False,
    driver_opts={
        "driver_opts_key": "driverOpts"
    },
    labels={
        "labels_key": "labels"
    }
)
```

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.ecs.*;

DockerVolumeConfiguration dockerVolumeConfiguration = DockerVolumeConfiguration.builder()
        .driver("driver")
        .scope(Scope.TASK)

        // the properties below are optional
        .autoprovision(false)
        .driverOpts(Map.of(
                "driverOptsKey", "driverOpts"))
        .labels(Map.of(
                "labelsKey", "labels"))
        .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.ECS;

var dockerVolumeConfiguration = new DockerVolumeConfiguration {
    Driver = "driver",
    Scope = Scope.TASK,

    // the properties below are optional
    Autoprovision = false,
    DriverOpts = new Dictionary<string, string> {
        { "driverOptsKey", "driverOpts" }
    },
    Labels = new Dictionary<string, string> {
        { "labelsKey", "labels" }
    }
};
```

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"

dockerVolumeConfiguration := &DockerVolumeConfiguration{
	Driver: jsii.String("driver"),
	Scope: awscdk.Aws_ecs.Scope_TASK,

	// the properties below are optional
	Autoprovision: jsii.Boolean(false),
	DriverOpts: map[string]*string{
		"driverOptsKey": jsii.String("driverOpts"),
	},
	Labels: map[string]*string{
		"labelsKey": jsii.String("labels"),
	},
}
```

## Properties

- `autoprovision`: boolean = false — Specifies whether the Docker volume should be created if it does not already exist.

  If true is specified, the Docker volume will be created for you.

- `driver`: string (required) — The Docker volume driver to use.

- `driverOpts`: { [key: string]: string } — A map of Docker driver-specific options passed through.

  **Default:** No options

- `labels`: { [key: string]: string } — Custom metadata to add to your Docker volume.

  **Default:** No labels

- `scope`: [Scope](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.Scope.html) (required) — The scope for the Docker volume that determines its lifecycle.
