Skip to content
v2.277.0

LinuxParametersProps Struct ​

The properties for defining Linux-specific options that are applied to the container.

Example ​

ts
declare const taskDefinition: ecs.TaskDefinition;

taskDefinition.addContainer('container', {
  image: ecs.ContainerImage.fromRegistry("amazon/amazon-ecs-sample"),
  memoryLimitMiB: 1024,
  linuxParameters: new ecs.LinuxParameters(this, 'LinuxParameters', {
    initProcessEnabled: true,
    sharedMemorySize: 1024,
    maxSwap: Size.mebibytes(5000),
    swappiness: 90,
  }),
});
python
# task_definition: ecs.TaskDefinition


task_definition.add_container("container",
    image=ecs.ContainerImage.from_registry("amazon/amazon-ecs-sample"),
    memory_limit_mi_b=1024,
    linux_parameters=ecs.LinuxParameters(self, "LinuxParameters",
        init_process_enabled=True,
        shared_memory_size=1024,
        max_swap=Size.mebibytes(5000),
        swappiness=90
    )
)
java
TaskDefinition taskDefinition;


taskDefinition.addContainer("container", ContainerDefinitionOptions.builder()
        .image(ContainerImage.fromRegistry("amazon/amazon-ecs-sample"))
        .memoryLimitMiB(1024)
        .linuxParameters(LinuxParameters.Builder.create(this, "LinuxParameters")
                .initProcessEnabled(true)
                .sharedMemorySize(1024)
                .maxSwap(Size.mebibytes(5000))
                .swappiness(90)
                .build())
        .build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
TaskDefinition taskDefinition;


taskDefinition.AddContainer("container", new ContainerDefinitionOptions {
    Image = ContainerImage.FromRegistry("amazon/amazon-ecs-sample"),
    MemoryLimitMiB = 1024,
    LinuxParameters = new LinuxParameters(this, "LinuxParameters", new LinuxParametersProps {
        InitProcessEnabled = true,
        SharedMemorySize = 1024,
        MaxSwap = Size.Mebibytes(5000),
        Swappiness = 90
    })
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var taskDefinition TaskDefinition


taskDefinition.AddContainer(jsii.String("container"), &ContainerDefinitionOptions{
	Image: ecs.ContainerImage_FromRegistry(jsii.String("amazon/amazon-ecs-sample")),
	MemoryLimitMiB: jsii.Number(1024),
	LinuxParameters: ecs.NewLinuxParameters(this, jsii.String("LinuxParameters"), &LinuxParametersProps{
		InitProcessEnabled: jsii.Boolean(true),
		SharedMemorySize: jsii.Number(1024),
		MaxSwap: awscdk.Size_Mebibytes(jsii.Number(5000)),
		Swappiness: jsii.Number(90),
	}),
})

Properties ​

initProcessEnabledoptionalbooleaninit_process_enabledoptionalboolinitProcessEnabledoptionalBooleanInitProcessEnabledoptionalboolInitProcessEnabledoptional*bool= false#
Specifies whether to run an init process inside the container that forwards signals and reaps processes.
maxSwapoptionalSizemax_swapoptionalSizemaxSwapoptionalSizeMaxSwapoptionalSizeMaxSwapoptionalSize#
The total amount of swap memory a container can use.

Default: No swap.

This parameter will be translated to the --memory-swap option to docker run.

This parameter is only supported when you are using the EC2 launch type. Accepted values are positive integers.

sharedMemorySizeoptionalnumbershared_memory_sizeoptionalint | floatsharedMemorySizeoptionalNumberSharedMemorySizeoptionaldoubleSharedMemorySizeoptional*float64#
The value for the size of the /dev/shm volume.

Default: No shared memory.

swappinessoptionalnumberswappinessoptionalint | floatswappinessoptionalNumberSwappinessoptionaldoubleSwappinessoptional*float64= 60#
This allows you to tune a container's memory swappiness behavior.
notes

This parameter maps to the --memory-swappiness option to docker run. The swappiness relates to the kernel's tendency to swap memory. A value of 0 will cause swapping to not happen unless absolutely necessary. A value of 100 will cause pages to be swapped very aggressively.

This parameter is only supported when you are using the EC2 launch type. Accepted values are whole numbers between 0 and 100. If a value is not specified for maxSwap then this parameter is ignored.