Menu
AWS CloudFormation
User Guide (API Version 2010-05-15)

Amazon Elastic Container Service TaskDefinition ContainerDefinition

The ContainerDefinition property type describes the configuration of an Amazon Elastic Container Service (Amazon ECS) container. The container definitions are passed to the Docker daemon.

The ContainerDefinitions property of the AWS::ECS::TaskDefinition resource contains a list of ContainerDefinition property types.

Syntax

JSON

{ "Command" : [ String, ... ], "Cpu" : Integer, "DisableNetworking" : Boolean, "DnsSearchDomains" : [ String, ... ], "DnsServers" : [ String, ... ], "DockerLabels" : { String:String, ... }, "DockerSecurityOptions" : [ String, ... ], "EntryPoint" : [ String, ... ], "Environment" : [ KeyValuePair, ... ], "Essential" : Boolean, "ExtraHosts" : [ HostEntry, ... ], "Hostname" : String, "Image" : String, "Links" : [ String, ... ], "LinuxParameters" : LinuxParameters, "LogConfiguration" : LogConfiguration, "Memory" : Integer, "MemoryReservation" : Integer, "MountPoints" : [ MountPoint, ... ], "Name" : String, "PortMappings" : [ PortMapping, ... ], "Privileged" : Boolean, "ReadonlyRootFilesystem" : Boolean, "Ulimits" : [ Ulimit, ... ], "User" : String, "VolumesFrom" : [ VolumeFrom, ... ], "WorkingDirectory" : String }

Properties

For more information about each property, see Task Definition Parameters in the Amazon Elastic Container Service Developer Guide.

Command

The CMD value to pass to the container. For more information about the Docker CMD parameter, see https://docs.docker.com/engine/reference/builder/#cmd.

Required: No

Type: List of String values

Cpu

The minimum number of CPU units to reserve for the container. Containers share unallocated CPU units with other containers on the instance by using the same ratio as their allocated CPU units. For more information, see the cpu content for the ContainerDefinition data type in the Amazon Elastic Container Service API Reference.

Required: No

Type: Integer

DisableNetworking

Indicates whether networking is disabled within the container.

Required: No

Type: Boolean

DnsSearchDomains

A list of DNS search domains that are provided to the container. The domain names that the DNS logic looks up when a process attempts to access a bare unqualified hostname.

Required: No

Type: List of String values

DnsServers

A list of DNS servers that Amazon ECS provides to the container.

Required: No

Type: List of String values

DockerLabels

A key-value map of labels for the container.

Required: No

Type: Key-value pairs, with the name of the label as the key and the label value as the value.

DockerSecurityOptions

A list of custom labels for SELinux and AppArmor multi-level security systems. For more information, see the dockerSecurityOptions content for the ContainerDefinition data type in the Amazon Elastic Container Service API Reference.

Required: No

Type: List of String values

EntryPoint

The ENTRYPOINT value to pass to the container. For more information about the Docker ENTRYPOINT parameter, see https://docs.docker.com/engine/reference/builder/#entrypoint.

Required: No

Type: List of String values

Environment

The environment variables to pass to the container.

Required: No

Type: List of Amazon ECS TaskDefinition KeyValuePair property types

Essential

Indicates whether the task stops if this container fails. If you specify true and the container fails, all other containers in the task stop. If you specify false and the container fails, none of the other containers in the task is affected. This value is true by default.

You must have at least one essential container in a task.

Required: No

Type: Boolean

ExtraHosts

A list of hostnames and IP address mappings to append to the /etc/hosts file on the container.

Required: No

Type: List of Amazon ECS TaskDefinition HostEntry property types

Hostname

The name that Docker uses for the container hostname.

Required: No

Type: String

Image

The image to use for a container. The image is passed directly to the Docker daemon. You can use images in the Docker Hub registry or specify other repositories (repository-url/image:tag).

Required: Yes

Type: String

Links

The name of another container to connect to. With links, containers can communicate with each other without using port mappings.

Required: No

Type: List of String values

LinuxParameters

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

Required: No

Type: Amazon ECS TaskDefinition LinuxParameters

LogConfiguration

Configures a custom log driver for the container. For more information, see the logConfiguration content for the ContainerDefinition data type in the Amazon Elastic Container Service API Reference.

Required: No

Type: Amazon ECS TaskDefinition LogConfiguration

Memory

The number of MiB of memory to reserve for the container. If your container attempts to exceed the allocated memory, the container is terminated.

Required: Conditional. You must specify one or both of the Memory or MemoryReservation properties. If you specify both, the value for the Memory property must be greater than the value of the MemoryReservation property.

Type: Integer

MemoryReservation

The number of MiB of memory to reserve for the container. When system memory is under contention, Docker attempts to keep the container memory within the limit. If the container requires more memory, it can consume up to the value specified by the Memory property or all of the available memory on the container instance—whichever comes first. This is called a soft limit.

Required: Conditional. You must specify one or both of the Memory or MemoryReservation properties. If you specify both, the value for the Memory property must be greater than the value of the MemoryReservation property.

Type: Integer

MountPoints

The mount points for data volumes in the container.

Required: No

Type: List of Amazon ECS TaskDefinition MountPoint property types

Name

A name for the container.

Required: Yes

Type: String

PortMappings

A mapping of the container port to a host port. Port mappings enable containers to access ports on the host container instance to send or receive traffic.

Required: No

Type: List of Amazon ECS TaskDefinition ContainerDefinitions PortMapping property types

Privileged

Indicates whether the container is given full access to the host container instance.

Required: No

Type: Boolean

ReadonlyRootFilesystem

Indicates whether the container's root file system is mounted as read only.

Required: No

Type: Boolean

Ulimits

A list of ulimits to set in the container. The ulimits set constraints on how many resources a container can consume so that it doesn't deplete all available resources on the host.

Required: No

Type: List of Amazon ECS TaskDefinition Ulimit property types

User

The user name to use inside the container.

Required: No

Type: String

VolumesFrom

The data volumes to mount from another container.

Required: No

Type: List of Amazon ECS TaskDefinition VolumeFrom property types

WorkingDirectory

The working directory in the container to run commands in.

Required: No

Type: String

See Also

On this page: