Skip to content
v2.277.0

DockerRunOptions Struct ​

Docker run options.

Example ​

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
# 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
// 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();
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"
};
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 ​

commandoptionalstring[]commandoptionaltyping.List[str]commandoptionalList<String>Commandoptionalstring[]Commandoptional*[]*string #
The command to run in the container.

Default: run the command defined in the image

entrypointoptionalstring[]entrypointoptionaltyping.List[str]entrypointoptionalList<String>Entrypointoptionalstring[]Entrypointoptional*[]*string #
The entrypoint to run in the container.

Default: run the entrypoint defined in the image

environmentoptional{ [key: string]: string }environmentoptionaltyping.Mapping[str, str]environmentoptionalMap<String, String>EnvironmentoptionalIDictionary<string, string>Environmentoptional*map[string]*string #
The environment variables to pass to the container.

Default: no environment variables.

networkoptionalstringnetworkoptionalstrnetworkoptionalStringNetworkoptionalstringNetworkoptional*string #

Default: no networking options

platformoptionalstringplatformoptionalstrplatformoptionalStringPlatformoptionalstringPlatformoptional*string #
Set platform if server is multi-platform capable. _Requires Docker Engine API v1.38+_.

Default: no platform specified

Example value: linux/amd64

securityOptoptionalstringsecurity_optoptionalstrsecurityOptoptionalStringSecurityOptoptionalstringSecurityOptoptional*string #
Security configuration when running the docker container.

Default: no security options

useroptionalstringuseroptionalstruseroptionalStringUseroptionalstringUseroptional*string #
The user to use when running the container.

Default: root or image default

volumesoptionalDockerVolume[]volumesoptionaltyping.List[DockerVolume]volumesoptionalList<DockerVolume>VolumesoptionalDockerVolume[]Volumesoptional*[]DockerVolume #
Docker volumes to mount.

Default: no volumes are mounted

volumesFromoptionalstring[]volumes_fromoptionaltyping.List[str]volumesFromoptionalList<String>VolumesFromoptionalstring[]VolumesFromoptional*[]*string #
Where to mount the specified volumes from.

Default: no containers are specified to mount volumes from

workingDirectoryoptionalstringworking_directoryoptionalstrworkingDirectoryoptionalStringWorkingDirectoryoptionalstringWorkingDirectoryoptional*string #
Working directory inside the container.

Default: image default