Amazon Elastic Container Service (Amazon ECS) allows you to easily run, scale, and secure Docker container applications on AWS. Applications packaged as containers locally will deploy and run in the same way as containers managed by Amazon ECS. Amazon ECS eliminates the need to install, operate, and scale your own container orchestration and cluster management infrastructure, and allows you to focus on the resource needs and availability requirements of your containerized application.
Amazon ECS enables you to grow from a single container to thousands of containers across hundreds of instances without creating additional complexity in how you run your application. You can run anything: applications, batch jobs, or microservices. Amazon ECS abstracts away all the complexity of the infrastructure so you can focus on designing, building, and running containerized applications.
With Amazon ECS, you can use AWS Fargate to fully manage your infrastructure and just focus on deploying containers Or, you can choose to have complete visibility and control of your underlying server cluster from creating and terminating Docker containers to viewing detailed cluster state information. You can integrate and use your own container scheduler or connect Amazon ECS into your existing software delivery process, such as continuous integration and delivery systems.
AWS Fargate Support
AWS Fargate technology is available with Amazon ECS. With AWS Fargate, you no longer have to select Amazon EC2 instance types, provision and scale clusters, or patch and update each server. You do not have to worry about task placement strategies, such as binpacking or host spread and tasks are automatically balanced across availability zones. Fargate manages the availability of containers for you. You just define your application’s requirements, select Fargate as your launch type in the console or CLI, and Fargate takes care of all the scaling and infrastructure management required to run your containers.
For developers who require more granular, server-level control over the infrastructure, Amazon ECS EC2 launch type allows you to manage a cluster of servers and schedule placement of containers on the servers.
Amazon ECS supports Docker and enables you to run and manage Docker containers. Applications you package as a container locally will deploy and run on Amazon ECS without the need for any configuration changes.
Windows Containers Compatibility
Amazon ECS supports management of Windows containers. An Amazon ECS-optimized Windows Amazon Machine Image (AMI) provides enhanced instance and container launch time performance and visibility into CPU, memory utilization, and reservation metrics.
The Amazon ECS CLI allows you to simplify your local development experience as well as easily set up and run your containers on Amazon ECS. The Amazon ECS CLI supports Docker Compose, an open-source tool for defining and running multi-container applications. You can apply the same Compose definition used to define a multi-container application on your development machine as well as in production. The Amazon ECS CLI is open-source. Download the Amazon ECS CLI.
Amazon ECS can be used with any third-party hosted Docker image repository or accessible private Docker registry, such as Docker Hub and Amazon Elastic Container Registry (Amazon ECR). All you need to do is specify the repository in your task definition and Amazon ECS retrieves the appropriate images for your applications.
Amazon ECS allows you to define tasks through a declarative JSON template called a Task Definition. Within a Task Definition you can specify one or more containers that are required for your task, including the Docker repository and image, memory and CPU requirements, shared data volumes, and how the containers are linked to each other. You can launch as many tasks as you want from a single Task Definition file that you can register with the service. Task Definition files also allow you to have version control over your application specification.
Amazon ECS provides you with a set of simple API actions to allow you to integrate and extend the service. The API actions allow you to create and delete clusters, register and deregister tasks, launch and terminate Docker containers, and provide detailed information about the state of your cluster and its instances. You can also use AWS CloudFormation to provision Amazon ECS clusters, register task definitions, and schedule containers.
Amazon ECS allows you to easily update your containers to new versions. You can upload a new version of your application task definition, and the Amazon ECS scheduler automatically starts new containers using the updated image and stop containers running the previous version. Amazon ECS automatically registers and deregisters your containers from the associated Application Load Balancer.
The Amazon ECS will automatically recover unhealthy containers to ensure that you have the desired number of containers supporting your application.
Amazon ECS offers two container launch types to deploy and run your containers. With the Fargate launch type, your container clusters are fully managed for you. The EC2 launch type allows you to have complete control and visibility of your underlying server cluster to support compliance and governance requirements or broader customization options. The following additional features are available with the EC2 launch type:
Amazon ECS includes schedulers that place containers across your clusters based on your resource needs (for example, CPU or RAM) and availability requirements. Using the available schedulers, you can schedule long-running applications and services as well as batch jobs.
The Amazon ECS API also provides you with complete cluster state information, allowing you to write your own schedulers or integrate existing third-party schedulers (for example, Marathon). Amazon ECS is a shared state, optimistic concurrency system that presents the full state of the cluster to all schedulers.
You can develop your own schedulers or integrate third-party schedulers by using the Amazon ECS API or Blox, a collection of open source projects for container management and orchestration. For more information, see the Blox GitHub page.
Task Placement Policies
Amazon ECS allows you to customize how tasks are placed based on built-in attributes such as instance type, Availability Zone, or custom attributes that you define. You can use attributes such as environment=production to label resources, use the list API actions to find those resources, and use the RunTask and CreateService API actions to schedule tasks on those resources. With Amazon ECS, you can also use placement strategies such as bin pack and spread to further define where tasks are placed. Policies can be chained together to achieve sophisticated placement capabilities without writing any code.
Networking and Security
Amazon Elastic Container Service supports Docker networking and integrates with Amazon VPC to provide isolation for containers. This gives you control over how containers connect with other services and external traffic. With Amazon ECS, you can choose between four networking modes for your containers that cater towards different use cases:
This mode assigns each running ECS task a dedicated elastic networking interface, allowing containers full networking features in a VPC, just like EC2 instances.
This mode creates a Linux bridge that connects all containers running on the host in a local virtual network, which can be accessed through the host's default network connection.
This mode adds containers directly to the host’s network stack, exposing containers on the host's network with no isolation.
This mode disables external networking for containers.
Amazon ECS is integrated with Elastic Load Balancing, allowing you to distribute traffic across your containers using Application Load Balancers or Network Load Balancers. You specify the task definition and the load balancer to use, and Amazon ECS automatically adds and removes containers from the load balancer. You can specify a dynamic port in the task definition, which gives your container an unused port when it is scheduled on an Amazon EC2 instance. You can also use path-based routing to share a load balancer with multiple services.
Amazon ECS includes service discovery that makes it easy for your containerized services to discover and connect with each other.
Amazon ECS creates and manages a registry of service names using the Route53 Auto Naming API so you can refer to a service by name in your code and write DNS queries to have the service name resolve to the service’s endpoint at runtime.
You can specify health check conditions in a service's task definition and Amazon ECS will ensure that only healthy service endpoints are returned by a service lookup.
Amazon ECS allows you to specify an IAM role for each ECS task. This allows the Amazon ECS container instances to have a minimal role, respecting the ‘least privilege’ access policy and allowing you to manage the instance role and the task role separately. You can also use Amazon CloudWatch Logs to gain visibility into the IAM role to which a task is assigned.
Monitoring and Logging
Amazon ECS provides monitoring capabilities for your containers and clusters through Amazon CloudWatch. You can monitor average and aggregate CPU and memory utilization of running tasks as grouped by task definition, service, or cluster. You can also set CloudWatch alarms to alert you when your containers or clusters need to scale up or down.
Amazon ECS allows you to record all your Amazon ECS API calls and have the log files delivered to you through AWS CloudTrail. The recorded information includes the identity of the API caller, the time of the API call, the source IP address of the API caller, the request parameters, and the response elements returned by Amazon ECS. CloudTrail provides you a history of API calls made from the AWS Management Console, AWS SDKs, and AWS CLI. It enables security analysis, resource change tracking, and compliance auditing.