# DockerRunOptions

Docker run options.

- Source: [`core/lib/bundling.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/aws-cdk-lib/core/lib/bundling.ts#L530)
- Type last changed: v2.88.0 · 20 Jul 2023

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
const dockerRunOptions: cdk.DockerRunOptions = {
  command: ['command'],
  entrypoint: ['entrypoint'],
  environment: {
    environmentKey: 'environment',
  },
  network: 'network',
  platform: 'platform',
  securityOpt: 'securityOpt',
  user: 'user',
  volumes: [{
    containerPath: 'containerPath',
    hostPath: 'hostPath',

    // the properties below are optional
    consistency: cdk.DockerVolumeConsistency.CONSISTENT,
  }],
  volumesFrom: ['volumesFrom'],
  workingDirectory: 'workingDirectory',
};
```

Python:

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

docker_run_options = cdk.DockerRunOptions(
    command=["command"],
    entrypoint=["entrypoint"],
    environment={
        "environment_key": "environment"
    },
    network="network",
    platform="platform",
    security_opt="securityOpt",
    user="user",
    volumes=[cdk.DockerVolume(
        container_path="containerPath",
        host_path="hostPath",

        # the properties below are optional
        consistency=cdk.DockerVolumeConsistency.CONSISTENT
    )],
    volumes_from=["volumesFrom"],
    working_directory="workingDirectory"
)
```

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

DockerRunOptions dockerRunOptions = DockerRunOptions.builder()
        .command(List.of("command"))
        .entrypoint(List.of("entrypoint"))
        .environment(Map.of(
                "environmentKey", "environment"))
        .network("network")
        .platform("platform")
        .securityOpt("securityOpt")
        .user("user")
        .volumes(List.of(DockerVolume.builder()
                .containerPath("containerPath")
                .hostPath("hostPath")

                // the properties below are optional
                .consistency(DockerVolumeConsistency.CONSISTENT)
                .build()))
        .volumesFrom(List.of("volumesFrom"))
        .workingDirectory("workingDirectory")
        .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;

var dockerRunOptions = new DockerRunOptions {
    Command = new [] { "command" },
    Entrypoint = new [] { "entrypoint" },
    Environment = new Dictionary<string, string> {
        { "environmentKey", "environment" }
    },
    Network = "network",
    Platform = "platform",
    SecurityOpt = "securityOpt",
    User = "user",
    Volumes = new [] { new DockerVolume {
        ContainerPath = "containerPath",
        HostPath = "hostPath",

        // the properties below are optional
        Consistency = DockerVolumeConsistency.CONSISTENT
    } },
    VolumesFrom = new [] { "volumesFrom" },
    WorkingDirectory = "workingDirectory"
};
```

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 cdk "github.com/aws/aws-cdk-go/awscdk"

dockerRunOptions := &DockerRunOptions{
	Command: []*string{
		jsii.String("command"),
	},
	Entrypoint: []*string{
		jsii.String("entrypoint"),
	},
	Environment: map[string]*string{
		"environmentKey": jsii.String("environment"),
	},
	Network: jsii.String("network"),
	Platform: jsii.String("platform"),
	SecurityOpt: jsii.String("securityOpt"),
	User: jsii.String("user"),
	Volumes: []DockerVolume{
		&DockerVolume{
			ContainerPath: jsii.String("containerPath"),
			HostPath: jsii.String("hostPath"),

			// the properties below are optional
			Consistency: cdk.DockerVolumeConsistency_CONSISTENT,
		},
	},
	VolumesFrom: []*string{
		jsii.String("volumesFrom"),
	},
	WorkingDirectory: jsii.String("workingDirectory"),
}
```

## Properties

- `command`: string[] — The command to run in the container.

  **Default:** run the command defined in the image

- `entrypoint`: string[] — The entrypoint to run in the container.

  **Default:** run the entrypoint defined in the image

- `environment`: { [key: string]: string } — The environment variables to pass to the container.

  **Default:** no environment variables.

- `network`: string — Docker [Networking options](https://docs.docker.com/engine/reference/commandline/run/#connect-a-container-to-a-network---network).

  **Default:** no networking options

- `platform`: string — Set platform if server is multi-platform capable. _Requires Docker Engine API v1.38+_.

  **Default:** no platform specified

  Example value: `linux/amd64`

- `securityOpt`: string — [Security configuration](https://docs.docker.com/engine/reference/run/#security-configuration) when running the docker container.

  **Default:** no security options

- `user`: string — The user to use when running the container.

  **Default:** root or image default

- `volumes`: [DockerVolume](/cdk/api/v2/docs/aws-cdk-lib.DockerVolume.html)[] — Docker volumes to mount.

  **Default:** no volumes are mounted

- `volumesFrom`: string[] — Where to mount the specified volumes from.

  **Default:** no containers are specified to mount volumes from

- `workingDirectory`: string — Working directory inside the container.

  **Default:** image default
