# Elastic Container Service (ECS)

## Essentials

* Container management service that supports Docker
* It allows you to easily create and manage a fleet of Docker containers on a cluster of EC2 instances.
  * Higher Instance Utilization
  * Consistency between all environments
  * Microservices
  * Continuous Deployment - automate builds
  * Load Balancing (ELB)
  * Autoscaling

### Components

* Docker Image
* Container Registry (ECR)
* Task Definitions
  * Docker Images
  * CPU, Memory
  * Launch Type - EC2 or Fargate (managed, serverless)
* ECS Cluster
  * EC2 Container Instances
    * [ECS Agents](/cloud-computing/aws/compute-services/elastic-container-service-ecs.md#ecs-agent)
      * Run [Tasks](/cloud-computing/aws/compute-services/elastic-container-service-ecs.md#ecs-tasks) from ECR

### ECS Agent

* Runs on each EC2 instance in the ECS cluster
* It communicates information about the instances to ECS, including:
  * Running tasks
  * Resource utilization
* The ECS agent is also responsible for starting/stopping tasks (when told to by ECS)

### ECS Tasks

* Actual representation of a Task Definition on an EC2 instance inside of your container cluster.
* ECS agent will start/stop these tasks based on instruction/schedule

#### Task Definition

* A JSON formatted text file that contains the "blueprint" for your application, including:
  * Which container/docker image to use
  * The repository (container registry) the image is located in
  * Which ports should be open on the container instance
  * What data volumes should be used with the container

#### Container/Docker Image

* Built from a Dockerfile
  * A plain text file (script) that specifies all of the components that are included in the container.
  * Instructions for what will be placed inside a given container.
* Contains all the downloaded software, code, runtime, system tools, and libraries (as outlined in the Dockerfile)
  * i.e. If the Dockerfile specifies PHP to be downloaded and installed, then the container/Docker Image will have PHP downloaded and installed.

### Elastic Container Service for Kubernetes (EKS)

* Manages availability and scalability of Kubernetes control plane nodes
  * Starts and stops containers
  * Schedule containers
  * Replaces unhealthy nodes


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gitbook.nicacton.com/cloud-computing/aws/compute-services/elastic-container-service-ecs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
