AWS Builder Center

Amazon ECS: Run Docker Containers on AWS

Learn Amazon ECS, task definitions, services, Fargate, and how ECR + ECS fit into a practical AWS container and CI/CD workflow.

Series: My 90-Day AWS & DevOps Learning Journey (19 articles)

  1. …
  2. 18
    Amazon ECS: Run Docker Containers on AWS This article

Amazon ECS: Run Docker Containers on AWS

After learning Docker, Docker Compose, and Amazon ECR, I reached the next question:
“How do I actually run my Docker container on AWS?”
That is where Amazon Elastic Container Service (Amazon ECS) comes in.

What is Amazon ECS?

Amazon ECS is a managed container orchestration service that helps us run and manage containerized applications on AWS.
The basic workflow looks like this:
1
2
3
4
5
6
7
8
9
10
11
Source Code
↓
Dockerfile
↓
Docker Image
↓
Amazon ECR
↓
Amazon ECS
↓
Running Container
This helped me understand that Docker is not just about running containers on my laptop. It can become part of a complete cloud deployment workflow.

Why Do We Need ECS?

Imagine we have a Dockerized web application.
We could manually connect to an EC2 instance and run the container, but as the application grows, we may need to manage:
  • Multiple containers
  • Container health
  • CPU and memory
  • Networking
  • Scaling
  • Container restarts
  • Deployments
Doing everything manually can become difficult.
ECS helps us manage container workloads without having to build the entire container orchestration system ourselves.

Important ECS Concepts

When I first started learning ECS, the terminology was one of the confusing parts.
Here are the important concepts I am learning.

1. ECS Cluster

A cluster provides a logical grouping for ECS workloads.
It acts as the environment where our ECS services and tasks run.

2. Task Definition

A task definition describes how our container should run.
It can define things such as:
1
2
3
4
5
6
Container Image
CPU
Memory
Port
Environment Variables
Logging
For example:
1
2
3
4
Image: my-app:latest
CPU: 512
Memory: 1 GB
Port: 8080

3. Task

A task is a running instance of a task definition.
If the task definition describes how the container should run, the task represents the actual running workload.

4. Service

An ECS service helps maintain the desired number of running tasks.
For example:
1
Desired tasks = 3
The service works to keep the required number of tasks running.
This becomes useful when we need availability and scaling.

ECS and Fargate

One of the interesting parts of ECS is that we can run containers using AWS Fargate.
With Fargate, AWS manages the underlying compute infrastructure, allowing us to focus more on the containers and applications.
The simplified architecture looks like:
1
2
3
4
5
6
7
ECS
↓
Fargate
↓
Container
↓
Application
This is especially interesting for beginners because we don't have to manage the underlying servers in the same way as a traditional EC2-based deployment.

ECR + ECS

This is where my previous Day 17 learning connects with today's topic.
Amazon ECR stores the container image.
Amazon ECS runs the container.
For example:
1
2
3
4
5
6
7
8
9
10
11
Docker Build
↓
Docker Image
↓
Amazon ECR
↓
Amazon ECS
↓
Fargate
↓
Running Application
Understanding this relationship made the overall container workflow much clearer to me.

Where Does CI/CD Fit?

Now we can connect everything to DevOps.
A developer pushes code:
1
2
3
4
5
6
7
8
9
10
11
12
13
Developer
↓
GitHub
↓
CI/CD Pipeline
↓
Build Docker Image
↓
Push Image to ECR
↓
Deploy to ECS
↓
New Application Version
This is where containerization becomes powerful.
Instead of manually deploying every change, a CI/CD pipeline can automate much of the process.

ECS vs EC2

Another thing I am learning is that ECS and EC2 are not simply alternatives to each other.
With EC2, we manage virtual servers and decide how applications run on them.
With ECS, we focus more on managing containerized applications.
For example:
1
2
3
4
5
EC2 approach:
Server → Install software → Deploy application

ECS approach:
Container Image → ECS → Run application
The best choice depends on the application's requirements.

My Learning Journey

My recent learning path is starting to connect:
Day 15: Docker
Day 16: Docker Compose
Day 17: Amazon ECR
Day 18: Amazon ECS
Instead of learning each technology separately, I am trying to understand how they work together in a real DevOps workflow:
Build → Store → Run → Deploy
That practical connection is making cloud and DevOps concepts much easier for me to understand.

💬 Let's Discuss

If you've worked with containers on AWS, what was the most confusing ECS concept when you first started?
Task definitions, networking, IAM permissions, Fargate, scaling, or connecting ECS with CI/CD?
If you're currently learning Docker, would you learn ECS next, or focus on Kubernetes first? Why?

Series: My 90-Day AWS & DevOps Learning Journey (19 articles)

  1. …
  2. 18
    Amazon ECS: Run Docker Containers on AWS This article
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article