AWS Builder Center

AWS ECS + Docker: What I Learned as a Beginner 🚀

When I started learning AWS, Docker and ECS looked like completely different technologies. After actually building and deploying an application, I realized how they fit together.

Aspiring DevOps Engineer
In this article, I'll share my beginner-level understanding of Docker and Amazon ECS, and the basic workflow I followed.

🐳 First: Why Docker?

Docker allows us to package an application together with its dependencies into a container.
Instead of installing Python, Flask, dependencies, and other requirements manually on every server, we can create a Docker image containing everything the application needs.
A simple workflow looks like:
Application → Dockerfile → Docker Image → Docker Container
For example, a Flask application can have a Dockerfile like:
FROM python:3.11-slim

WORKDIR /app

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

EXPOSE 8000

CMD ["python", "app.py"]
Then we can build and run it:
docker build -t my-flask-app .
docker run -p 8000:8000 my-flask-app
The important thing I learned is that a Docker image is the package/template, while a container is a running instance of that image.

☁️ Then I Learned About Amazon ECS

Amazon ECS (Elastic Container Service) is an AWS service for running and managing containers.
Instead of manually running Docker containers on a server, ECS can manage the containers for us.
The basic ECS structure was initially confusing, but this mental model helped me:
ECS Cluster
↓
ECS Service
↓
ECS Task
↓
Container
↓
Docker Image

ECS Cluster

The cluster is the logical place where our ECS workloads run.

ECS Task Definition

The task definition tells ECS how to run the container.
It can specify things such as:
  • Docker image
  • CPU
  • Memory
  • Container port
  • Environment variables
  • IAM roles
  • Logging

ECS Task

A task is a running instance of the configuration defined in the task definition.

ECS Service

The service helps keep the required number of tasks running.
For example:
Desired count = 2

ECS Service
/ \
Task 1 Task 2
If a task stops unexpectedly, ECS can start another one to maintain the desired count.

🚀 ECS + Docker + ECR

Another important part of the process was Amazon ECR.
ECR is a container image registry from AWS.
My overall workflow became:
Write Application
↓
Create Dockerfile
↓
docker build
↓
Docker Image
↓
Push Image to ECR
↓
ECS Task Definition
↓
ECS Service
↓
Running Container
This made the relationship between Docker, ECR and ECS much clearer to me.
Docker → builds the container image
ECR → stores the image
ECS → runs the container

🌐 Where Does the Load Balancer Come In?

When deploying a web application, I also learned about using an Application Load Balancer (ALB).
Instead of users directly accessing individual ECS tasks, traffic can go through the load balancer.
User
↓
Application Load Balancer
↓
ECS Service
↓
ECS Tasks
↓
Containers
The load balancer can also perform health checks to make sure traffic is sent to healthy tasks.

🧠 The Biggest Beginner Lesson

The biggest thing I learned wasn't a particular command.
It was understanding how all the pieces connect.
At first, I saw:
  • Docker
  • ECR
  • ECS
  • Task Definition
  • Service
  • Load Balancer
  • VPC
  • Security Groups
as separate things.
Now I think of them as parts of one deployment:
AWS
│
┌─────────┴─────────┐
│ │
ECR ECS
│ │
Docker Image Task Definition
│
Service
│
Tasks
│
Containers
│
Application Load
Balancer
│
Users

🔥 What I Would Tell Someone Starting Today

If you're learning ECS as a beginner, don't try to memorize every AWS console option.
First understand this:
Docker packages the application.
ECR stores the Docker image.
ECS runs the container.
The ECS service keeps the desired number of tasks running.
The load balancer sends user traffic to healthy tasks.
Once these relationships make sense, the AWS console becomes much easier to understand.
I'm still learning AWS and DevOps, but building this kind of deployment helped me understand containers much better than simply reading about them.
If you're also learning ECS, what part confused you the most when you started? I'd love to hear what you're working on.
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