# IEcsContainerDefinition

A container that can be run with ECS orchestration.

Extends: IEcsContainerDefinition
Extends: IConstruct
Implemented by: EcsEc2ContainerDefinition, EcsFargateContainerDefinition

- Source: [`aws-batch/lib/ecs-container-definition.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-batch/lib/ecs-container-definition.ts#L380)
- Type last changed: v2.215.0 · 15 Sep 2025

## Properties

- `command`: string[] — The command that's passed to the container.

- `cpu`: number — The number of vCPUs reserved for the container.

  Each vCPU is equivalent to 1,024 CPU shares.
  For containers running on EC2 resources, you must specify at least one vCPU.

- `enableExecuteCommand`: boolean — Whether to enable ecs exec for this container.

  **Default:** undefined - AWS Batch default is false

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

  **Default:** no environment variables

  Cannot start with `AWS_BATCH`.
  We don't recommend using plaintext environment variables for sensitive information, such as credential data.

- `executionRole`: [IRole](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) — The role used by Amazon ECS container and AWS Fargate agents to make AWS API calls on your behalf.

- `image`: [ContainerImage](/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.ContainerImage.html) — The image that this container will run.

- `jobRole`: [IRole](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) — The role that the container can assume.

  **Default:** no jobRole

- `linuxParameters`: [LinuxParameters](/cdk/api/v2/docs/aws-cdk-lib.aws_batch.LinuxParameters.html) = none — Linux-specific modifications that are applied to the container, such as details for device mappings.

- `logDriverConfig`: [LogDriverConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.LogDriverConfig.html) — The configuration of the log driver.

- `memory`: [Size](/cdk/api/v2/docs/aws-cdk-lib.Size.html) — The memory hard limit present to the container.

  If your container attempts to exceed the memory specified, the container is terminated.
  You must specify at least 4 MiB of memory for a job.

- `node`: [Node](/cdk/api/v2/docs/constructs.Node.html) — The tree node.

- `readonlyRootFilesystem`: boolean = false — Gives the container readonly access to its root filesystem.

- `secrets`: { [key: string]: [Secret](/cdk/api/v2/docs/aws-cdk-lib.aws_batch.Secret.html) } — A map from environment variable names to the secrets for the container.

  **Default:** no secrets

  Allows your job definitions
  to reference the secret by the environment variable name defined in this property.

- `user`: string — The user name to use inside the container.

  **Default:** no user

- `volumes`: [EcsVolume](/cdk/api/v2/docs/aws-cdk-lib.aws_batch.EcsVolume.html)[] — The volumes to mount to this container.

  **Default:** no volumes

  Automatically added to the job definition.

## Methods

- `addVolume(volume: EcsVolume): void` — Add a Volume to this container.

- `with(...mixins: IMixin[]): IConstruct` — Applies one or more mixins to this construct.

  Mixins are applied in order. The list of constructs is captured at the
  start of the call, so constructs added by a mixin will not be visited.

  **Parameters**

  - `mixins` — The mixins to apply.

  **Returns:** This construct for chaining
