AWS SDK Version 2 for .NET
API Reference

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.

.NET Framework 3.5
 
Container definitions are used in task definitions to describe the different containers that are launched as part of a task.

Inheritance Hierarchy

System.Object
  Amazon.ECS.Model.ContainerDefinition

Namespace: Amazon.ECS.Model
Assembly: AWSSDK.dll
Version: (assembly version)

Syntax

C#
public class ContainerDefinition : Object

The ContainerDefinition type exposes the following members

Constructors

NameDescription
Public Method ContainerDefinition()

Properties

NameTypeDescription
Public Property Command System.Collections.Generic.List<System.String> Gets and sets the property Command.

The command that is passed to the container. This parameter maps to Cmd in the Create a container section of the Docker Remote API and the COMMAND parameter to docker run. For more information, see https://docs.docker.com/reference/builder/#cmd.

Public Property Cpu System.Int32 Gets and sets the property Cpu.

The number of cpu units reserved for the container. A container instance has 1,024 cpu units for every CPU core. This parameter specifies the minimum amount of CPU to reserve for a container, and containers share unallocated CPU units with other containers on the instance with the same ratio as their allocated amount. This parameter maps to CpuShares in the Create a container section of the Docker Remote API and the --cpu-shares option to docker run.

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.

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 is 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 would be guaranteed a minimum of 512 CPU units when needed, and each container could float to higher CPU usage if the other container was not using it, but if both tasks were 100% active all of the time, they would be limited to 512 CPU units.

The Docker daemon on the container instance uses the CPU value to calculate the relative CPU share ratios for running containers. For more information, see CPU share constraint in the Docker documentation. The minimum valid CPU share value that the Linux kernel allows is 2; however, the CPU parameter is not required, and you can use CPU values below 2 in your container definitions. For CPU values below 2 (including null), the behavior varies based on your Amazon ECS container agent version:

  • Agent versions less than or equal to 1.1.0: Null and zero CPU values are passed to Docker as 0, which Docker then converts to 1,024 CPU shares. CPU values of 1 are passed to Docker as 1, which the Linux kernel converts to 2 CPU shares.
  • Agent versions greater than or equal to 1.2.0: Null, zero, and CPU values of 1 are passed to Docker as 2.
Public Property DisableNetworking System.Boolean Gets and sets the property DisableNetworking.

When this parameter is true, networking is disabled within the container. This parameter maps to NetworkDisabled in the Create a container section of the Docker Remote API.

Public Property 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 DnsSearch in the Create a container section of the Docker Remote API and the --dns-search option to docker run.

Public Property 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 Dns in the Create a container section of the Docker Remote API and the --dns option to docker run.

Public Property 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 Labels in the Create a container section of the Docker Remote API and the --label option to docker run. 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 into your container instance and run the following command:

sudo
            docker version | grep "Server API version"

Public Property DockerSecurityOptions System.Collections.Generic.List<System.String> Gets and sets the property DockerSecurityOptions.

A list of strings to provide custom labels for SELinux and AppArmor multi-level security systems. This parameter maps to SecurityOpt in the Create a container section of the Docker Remote API and the --security-opt option to docker run.

The Amazon ECS container agent running on a container instance must register with the ECS_SELINUX_CAPABLE=true or ECS_APPARMOR_CAPABLE=true environment variables before containers placed on that instance can use these security options. For more information, see Amazon ECS Container Agent Configuration in the Amazon EC2 Container Service Developer Guide.

Public Property EntryPoint System.Collections.Generic.List<System.String> Gets and sets the property EntryPoint.

Early versions of the Amazon ECS container agent do not properly handle entryPoint parameters. If you have problems using entryPoint, update your container agent or enter your commands and arguments as command array items instead.

The entry point that is passed to the container. This parameter maps to Entrypoint in the Create a container section of the Docker Remote API and the --entrypoint option to docker run. For more information, see https://docs.docker.com/reference/builder/#entrypoint.

Public Property 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 Env in the Create a container section of the Docker Remote API and the --env option to docker run.

We do not recommend using plain text environment variables for sensitive information, such as credential data.

Public Property Essential System.Boolean Gets and sets the property Essential.

If the essential parameter of a container is marked as true, the failure of that container stops the task. If the essential parameter of a container is marked as false, then its failure does not affect the rest of the containers in a task. If this parameter is omitted, a container is assumed to be essential.

All tasks must have at least one essential container.

Public Property 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 /etc/hosts file on the container. This parameter maps to ExtraHosts in the Create a container section of the Docker Remote API and the --add-host option to docker run.

Public Property Hostname System.String Gets and sets the property Hostname.

The hostname to use for your container. This parameter maps to Hostname in the Create a container section of the Docker Remote API and the --hostname option to docker run.

Public Property 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. Images in the Docker Hub registry are available by default. Other repositories are specified with repository-url/image:tag. Up to 255 letters (uppercase and lowercase), numbers, hyphens, underscores, colons, periods, forward slashes, and number signs are allowed. This parameter maps to Image in the Create a container section of the Docker Remote API and the IMAGE parameter of docker run.

  • Images in official repositories on Docker Hub use a single name (for example, ubuntu or mongo).
  • Images in other repositories on Docker Hub are qualified with an organization name (for example, amazon/amazon-ecs-agent).
  • Images in other online repositories are qualified further by a domain name (for example, quay.io/assemblyline/ubuntu).
Public Property Links System.Collections.Generic.List<System.String> Gets and sets the property Links.

The link parameter allows containers to communicate with each other without the need for port mappings, using the name parameter and optionally, an alias for the link. This construct is analogous to name:alias in Docker links. Up to 255 letters (uppercase and lowercase), numbers, hyphens, and underscores are allowed for each name and alias. For more information on linking Docker containers, see https://docs.docker.com/userguide/dockerlinks/. This parameter maps to Links in the Create a container section of the Docker Remote API and the --link option to

docker
            run
.

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.

Public Property LogConfiguration Amazon.ECS.Model.LogConfiguration Gets and sets the property LogConfiguration.

The log configuration specification for the container. This parameter maps to LogConfig in the Create a container section of the Docker Remote API and the --log-driver option to docker run. Valid log drivers are displayed in the LogConfiguration data type. 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 into your container instance and run the following command:

sudo docker version |
            grep "Server API version"

The Amazon ECS container agent running on a container instance must register the logging drivers available on that instance with the ECS_AVAILABLE_LOGGING_DRIVERS environment variable before containers placed on that instance can use these log configuration options. For more information, see Amazon ECS Container Agent Configuration in the Amazon EC2 Container Service Developer Guide.

Public Property Memory System.Int32 Gets and sets the property Memory.

The number of MiB of memory to reserve for the container. You must specify a non-zero integer for this parameter; the Docker daemon reserves a minimum of 4 MiB of memory for a container, so you should not specify fewer than 4 MiB of memory for your containers. If your container attempts to exceed the memory allocated here, the container is killed. This parameter maps to Memory in the Create a container section of the Docker Remote API and the --memory option to docker run.

Public Property 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 Volumes in the Create a container section of the Docker Remote API and the --volume option to docker run.

Public Property Name System.String Gets and sets the property Name.

The name of a container. If you are linking multiple containers together in a task definition, the name of one container can be entered in the links of another container to connect the containers. Up to 255 letters (uppercase and lowercase), numbers, hyphens, and underscores are allowed. This parameter maps to name in the Create a container section of the Docker Remote API and the --name option to docker run.

Public Property 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. This parameter maps to PortBindings in the Create a container section of the Docker Remote API and the --publish option to docker run.

After a task reaches the RUNNING status, manual and automatic host and container port assignments are visible in the Network Bindings section of a container description of a selected task in the Amazon ECS console, or the networkBindings section DescribeTasks responses.

Public Property 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 root user). This parameter maps to Privileged in the Create a container section of the Docker Remote API and the --privileged option to docker run.

Public Property 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 ReadonlyRootfs in the Create a container section of the Docker Remote API and the --read-only option to docker run.

Public Property Ulimits System.Collections.Generic.List<Amazon.ECS.Model.Ulimit> Gets and sets the property Ulimits.

A list of ulimits to set in the container. This parameter maps to Ulimits in the Create a container section of the Docker Remote API and the --ulimit option to docker run. Valid naming values are displayed in the Ulimit data type. 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 into your container instance and run the following command:

sudo docker version | grep "Server API
            version"

Public Property User System.String Gets and sets the property User.

The user name to use inside the container. This parameter maps to User in the Create a container section of the Docker Remote API and the --user option to docker run.

Public Property 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 VolumesFrom in the Create a container section of the Docker Remote API and the --volumes-from option to docker run.

Public Property WorkingDirectory System.String Gets and sets the property WorkingDirectory.

The working directory in which to run commands inside the container. This parameter maps to WorkingDir in the Create a container section of the Docker Remote API and the --workdir option to docker run.

Version Information

.NET Framework:
Supported in: 4.5, 4.0, 3.5

.NET for Windows Store apps:
Supported in: Windows 8