AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.
Container definitions are used in task definitions to describe the different containers that are launched as part of a task.
Namespace: Amazon.ECS.Model
Assembly: AWSSDK.ECS.dll
Version: 3.x.y.z
public class ContainerDefinition
The ContainerDefinition type exposes the following members
Name | Description | |
---|---|---|
![]() |
ContainerDefinition() |
Name | Type | Description | |
---|---|---|---|
![]() |
Command | System.Collections.Generic.List<System.String> |
Gets and sets the property Command.
The command that's passed to the container. This parameter maps to |
![]() |
Cpu | System.Int32 |
Gets and sets the property Cpu.
The number of
This field is optional for tasks using the Fargate launch type, and the only requirement
is that the total amount of CPU reserved for all containers within a task be lower
than the task-level You can determine the number of CPU units that are available per EC2 instance type by multiplying the vCPUs listed for that instance type on the Amazon EC2 Instances detail page by 1,024. Linux containers share unallocated CPU units with other containers on the container instance with the same ratio as their allocated amount. For example, if you run a single-container task on a single-core instance type with 512 CPU units specified for that container, and that's the only task running on the container instance, that container could use the full 1,024 CPU unit share at any given time. However, if you launched another copy of the same task on that container instance, each task is guaranteed a minimum of 512 CPU units when needed. Moreover, each container could float to higher CPU usage if the other container was not using it. If both tasks were 100% active all of the time, they would be limited to 512 CPU units. On Linux container instances, the Docker daemon on the container instance uses the CPU value to calculate the relative CPU share ratios for running containers. The minimum valid CPU share value that the Linux kernel allows is 2, and the maximum valid CPU share value that the Linux kernel allows is 262144. However, the CPU parameter isn't required, and you can use CPU values below 2 or above 262144 in your container definitions. For CPU values below 2 (including null) or above 262144, the behavior varies based on your Amazon ECS container agent version:
On Windows container instances, the CPU limit is enforced as an absolute limit, or
a quota. Windows containers only have access to the specified amount of CPU that's
described in the task definition. A null or zero CPU value is passed to Docker as
|
![]() |
CredentialSpecs | System.Collections.Generic.List<System.String> |
Gets and sets the property CredentialSpecs.
A list of ARNs in SSM or Amazon S3 to a credential spec ( There are two formats for each ARN.
In both formats, replace
If you provide a |
![]() |
DependsOn | System.Collections.Generic.List<Amazon.ECS.Model.ContainerDependency> |
Gets and sets the property DependsOn. The dependencies defined for container startup and shutdown. A container can contain multiple dependencies on other containers in a task definition. When a dependency is defined for container startup, for container shutdown it is reversed.
For tasks using the EC2 launch type, the container instances require at least version
1.26.0 of the container agent to turn on container dependencies. However, we recommend
using the latest container agent version. For information about checking your agent
version and updating to the latest version, see Updating
the Amazon ECS Container Agent in the Amazon Elastic Container Service Developer
Guide. If you're using an Amazon ECS-optimized Linux AMI, your instance needs
at least version 1.26.0-1 of the For tasks using the Fargate launch type, the task or service requires the following platforms:
|
![]() |
DisableNetworking | System.Boolean |
Gets and sets the property DisableNetworking.
When this parameter is true, networking is off within the container. This parameter
maps to This parameter is not supported for Windows containers. |
![]() |
DnsSearchDomains | System.Collections.Generic.List<System.String> |
Gets and sets the property DnsSearchDomains.
A list of DNS search domains that are presented to the container. This parameter maps
to This parameter is not supported for Windows containers. |
![]() |
DnsServers | System.Collections.Generic.List<System.String> |
Gets and sets the property DnsServers.
A list of DNS servers that are presented to the container. This parameter maps to
This parameter is not supported for Windows containers. |
![]() |
DockerLabels | System.Collections.Generic.Dictionary<System.String, System.String> |
Gets and sets the property DockerLabels.
A key/value map of labels to add to the container. This parameter maps to |
![]() |
DockerSecurityOptions | System.Collections.Generic.List<System.String> |
Gets and sets the property DockerSecurityOptions. A list of strings to provide custom configuration for multiple security systems. This field isn't valid for containers in tasks using the Fargate launch type. For Linux tasks on EC2, this parameter can be used to reference custom labels for SELinux and AppArmor multi-level security systems. For any tasks on EC2, this parameter can be used to reference a credential spec file that configures a container for Active Directory authentication. For more information, see Using gMSAs for Windows Containers and Using gMSAs for Linux Containers in the Amazon Elastic Container Service Developer Guide.
This parameter maps to
The Amazon ECS container agent running on a container instance must register with
the Valid values: "no-new-privileges" | "apparmor:PROFILE" | "label:value" | "credentialspec:CredentialSpecFilePath" |
![]() |
EntryPoint | System.Collections.Generic.List<System.String> |
Gets and sets the property EntryPoint.
Early versions of the Amazon ECS container agent don't properly handle
The entry point that's passed to the container. This parameter maps to |
![]() |
Environment | System.Collections.Generic.List<Amazon.ECS.Model.KeyValuePair> |
Gets and sets the property Environment.
The environment variables to pass to a container. This parameter maps to We don't recommend that you use plaintext environment variables for sensitive information, such as credential data. |
![]() |
EnvironmentFiles | System.Collections.Generic.List<Amazon.ECS.Model.EnvironmentFile> |
Gets and sets the property EnvironmentFiles.
A list of files containing the environment variables to pass to a container. This
parameter maps to the
You can specify up to ten environment files. The file must have a
If there are environment variables specified using the |
![]() |
Essential | System.Boolean |
Gets and sets the property Essential.
If the All tasks must have at least one essential container. If you have an application that's composed of multiple containers, group containers that are used for a common purpose into components, and separate the different components into multiple task definitions. For more information, see Application Architecture in the Amazon Elastic Container Service Developer Guide. |
![]() |
ExtraHosts | System.Collections.Generic.List<Amazon.ECS.Model.HostEntry> |
Gets and sets the property ExtraHosts.
A list of hostnames and IP address mappings to append to the
This parameter isn't supported for Windows containers or tasks that use the |
![]() |
FirelensConfiguration | Amazon.ECS.Model.FirelensConfiguration |
Gets and sets the property FirelensConfiguration. The FireLens configuration for the container. This is used to specify and configure a log router for container logs. For more information, see Custom Log Routing in the Amazon Elastic Container Service Developer Guide. |
![]() |
HealthCheck | Amazon.ECS.Model.HealthCheck |
Gets and sets the property HealthCheck.
The container health check command and associated configuration parameters for the
container. This parameter maps to |
![]() |
Hostname | System.String |
Gets and sets the property Hostname.
The hostname to use for your container. This parameter maps to
The |
![]() |
Image | System.String |
Gets and sets the property Image.
The image used to start a container. This string is passed directly to the Docker
daemon. By default, images in the Docker Hub registry are available. Other repositories
are specified with either
|
![]() |
Interactive | System.Boolean |
Gets and sets the property Interactive.
When this parameter is |
![]() |
Links | System.Collections.Generic.List<System.String> |
Gets and sets the property Links.
The This parameter is not supported for Windows containers. Containers that are collocated on a single container instance may be able to communicate with each other without requiring links or host port mappings. Network isolation is achieved on the container instance using security groups and VPC settings. |
![]() |
LinuxParameters | Amazon.ECS.Model.LinuxParameters |
Gets and sets the property LinuxParameters. Linux-specific modifications that are applied to the default Docker container configuration, such as Linux kernel capabilities. For more information see KernelCapabilities. This parameter is not supported for Windows containers. |
![]() |
LogConfiguration | Amazon.ECS.Model.LogConfiguration |
Gets and sets the property LogConfiguration. The log configuration specification for the container.
This parameter maps to Amazon ECS currently supports a subset of the logging drivers available to the Docker daemon (shown in the LogConfiguration data type). Additional log drivers may be available in future releases of the Amazon ECS container agent.
This parameter requires version 1.18 of the Docker Remote API or greater on your container
instance. To check the Docker Remote API version on your container instance, log in
to your container instance and run the following command:
The Amazon ECS container agent running on a container instance must register the logging
drivers available on that instance with the |
![]() |
Memory | System.Int32 |
Gets and sets the property Memory.
The amount (in MiB) of memory to present to the container. If your container attempts
to exceed the memory specified here, the container is killed. The total amount of
memory reserved for all containers within a task must be lower than the task If using the Fargate launch type, this parameter is optional.
If using the EC2 launch type, you must specify either a task-level memory value or
a container-level memory value. If you specify both a container-level The Docker 20.10.0 or later daemon reserves a minimum of 6 MiB of memory for a container. So, don't specify less than 6 MiB of memory for your containers. The Docker 19.03.13-ce or earlier daemon reserves a minimum of 4 MiB of memory for a container. So, don't specify less than 4 MiB of memory for your containers. |
![]() |
MemoryReservation | System.Int32 |
Gets and sets the property MemoryReservation.
The soft limit (in MiB) of memory to reserve for the container. When system memory
is under heavy contention, Docker attempts to keep the container memory to this soft
limit. However, your container can consume more memory when it needs to, up to either
the hard limit specified with the
If a task-level memory value is not specified, you must specify a non-zero integer
for one or both of
For example, if your container normally uses 128 MiB of memory, but occasionally bursts
to 256 MiB of memory for short periods of time, you can set a The Docker 20.10.0 or later daemon reserves a minimum of 6 MiB of memory for a container. So, don't specify less than 6 MiB of memory for your containers. The Docker 19.03.13-ce or earlier daemon reserves a minimum of 4 MiB of memory for a container. So, don't specify less than 4 MiB of memory for your containers. |
![]() |
MountPoints | System.Collections.Generic.List<Amazon.ECS.Model.MountPoint> |
Gets and sets the property MountPoints. The mount points for data volumes in your container.
This parameter maps to
Windows containers can mount whole directories on the same drive as |
![]() |
Name | System.String |
Gets and sets the property Name.
The name of a container. If you're linking multiple containers together in a task
definition, the |
![]() |
PortMappings | System.Collections.Generic.List<Amazon.ECS.Model.PortMapping> |
Gets and sets the property PortMappings. The list of port mappings for the container. Port mappings allow containers to access ports on the host container instance to send or receive traffic.
For task definitions that use the
Port mappings on Windows use the
This parameter maps to
After a task reaches the |
![]() |
Privileged | System.Boolean |
Gets and sets the property Privileged.
When this parameter is true, the container is given elevated privileges on the host
container instance (similar to the This parameter is not supported for Windows containers or tasks run on Fargate. |
![]() |
PseudoTerminal | System.Boolean |
Gets and sets the property PseudoTerminal.
When this parameter is |
![]() |
ReadonlyRootFilesystem | System.Boolean |
Gets and sets the property ReadonlyRootFilesystem.
When this parameter is true, the container is given read-only access to its root file
system. This parameter maps to This parameter is not supported for Windows containers. |
![]() |
RepositoryCredentials | Amazon.ECS.Model.RepositoryCredentials |
Gets and sets the property RepositoryCredentials. The private repository authentication credentials to use. |
![]() |
ResourceRequirements | System.Collections.Generic.List<Amazon.ECS.Model.ResourceRequirement> |
Gets and sets the property ResourceRequirements. The type and amount of a resource to assign to a container. The only supported resource is a GPU. |
![]() |
RestartPolicy | Amazon.ECS.Model.ContainerRestartPolicy |
Gets and sets the property RestartPolicy. The restart policy for a container. When you set up a restart policy, Amazon ECS can restart the container without needing to replace the task. For more information, see Restart individual containers in Amazon ECS tasks with container restart policies in the Amazon Elastic Container Service Developer Guide. |
![]() |
Secrets | System.Collections.Generic.List<Amazon.ECS.Model.Secret> |
Gets and sets the property Secrets. The secrets to pass to the container. For more information, see Specifying Sensitive Data in the Amazon Elastic Container Service Developer Guide. |
![]() |
StartTimeout | System.Int32 |
Gets and sets the property StartTimeout.
Time duration (in seconds) to wait before giving up on resolving dependencies for
a container. For example, you specify two containers in a task definition with containerA
having a dependency on containerB reaching a
When the For tasks using the Fargate launch type, the task or service requires the following platforms:
For tasks using the EC2 launch type, your container instances require at least version
The valid values for Fargate are 2-120 seconds. |
![]() |
StopTimeout | System.Int32 |
Gets and sets the property StopTimeout. Time duration (in seconds) to wait before the container is forcefully killed if it doesn't exit normally on its own. For tasks using the Fargate launch type, the task or service requires the following platforms:
For tasks that use the Fargate launch type, the max stop timeout value is 120 seconds and if the parameter is not specified, the default value of 30 seconds is used.
For tasks that use the EC2 launch type, if the The valid values for Fargate are 2-120 seconds. |
![]() |
SystemControls | System.Collections.Generic.List<Amazon.ECS.Model.SystemControl> |
Gets and sets the property SystemControls.
A list of namespaced kernel parameters to set in the container. This parameter maps
to |
![]() |
Ulimits | System.Collections.Generic.List<Amazon.ECS.Model.Ulimit> |
Gets and sets the property Ulimits.
A list of
Amazon ECS tasks hosted on Fargate use the default resource limit values set by the
operating system with the exception of the
This parameter requires version 1.18 of the Docker Remote API or greater on your container
instance. To check the Docker Remote API version on your container instance, log in
to your container instance and run the following command: This parameter is not supported for Windows containers. |
![]() |
User | System.String |
Gets and sets the property User.
The user to use inside the container. This parameter maps to
When running tasks using the
You can specify the
This parameter is not supported for Windows containers. |
![]() |
VersionConsistency | Amazon.ECS.VersionConsistency |
Gets and sets the property VersionConsistency.
Specifies whether Amazon ECS will resolve the container image tag provided in the
container definition to an image digest. By default, the value is |
![]() |
VolumesFrom | System.Collections.Generic.List<Amazon.ECS.Model.VolumeFrom> |
Gets and sets the property VolumesFrom.
Data volumes to mount from another container. This parameter maps to |
![]() |
WorkingDirectory | System.String |
Gets and sets the property WorkingDirectory.
The working directory to run commands inside the container in. This parameter maps
to |
.NET:
Supported in: 8.0 and newer, Core 3.1
.NET Standard:
Supported in: 2.0
.NET Framework:
Supported in: 4.5 and newer, 3.5