AWS ECR, ECS & Container Orchestration
Pankaj Yadav / April 25, 2026
Modern applications are commonly deployed using containers. AWS provides services such as Elastic Container Registry (ECR) and Elastic Container Service (ECS) to simplify deployment and scaling.
This guide explains how to containerize a Node.js application, push Docker images to AWS ECR, and deploy applications using ECS and Fargate.
What is ECR?
ECR (Elastic Container Registry) is AWS's managed Docker image registry.
It helps developers:
- Store container images securely
- Manage versions of Docker images
- Deploy directly to ECS or EKS
- Scale repositories automatically
Features of ECR
- Private repositories
- ECS & EKS integration
- Automatic scaling
- IAM-based security
What is ECS?
ECS (Elastic Container Service) is AWS's container orchestration platform.
It helps:
- Deploy containers
- Scale services
- Manage infrastructure
- Recover failed containers
ECS Concepts
Cluster
A cluster is a group of resources where containers run.
EC2 Cluster
You manage the servers.
Fargate Cluster
AWS manages infrastructure for you.
You only configure:
- CPU
- Memory
- Container image
Task Definition
A task definition is a blueprint for containers.
It defines:
- Docker image
- CPU and memory
- Networking
- Environment variables
- Port mappings
Service
A service ensures containers continue running.
It handles:
- Scaling
- Auto recovery
- Load balancing
Containerizing a Node.js App
Initialize Bun App
bun init
Install Express
bun add express @types/express
Create Basic App
import express from 'express'
const app = express()
app.get('/cpu', (req, res) => {
for (let i = 0; i < 100000000; i++) {
Math.random()
}
res.send('Hello world')
})
app.get('/', (req, res) => {
res.send('hii')
})
app.listen(3000)
Create Dockerfile
Create a file named Dockerfile.
FROM oven/bun:alpine
WORKDIR /app
COPY . .
RUN bun install
CMD ["bun", "run", "index.ts"]
Build Docker Image
docker build -t node-app .
For Apple Silicon:
docker build --platform=linux/amd64 -t node-app .
Run Container
docker run -p 3000:3000 node-app
Visit:
http://localhost:3000
Creating ECR Repository
Step 1: Open ECR
Create a repository.
Choose:
Private Repository
Step 2: Create IAM Credentials
Generate:
- Access Key ID
- Secret Access Key
Step 3: Install AWS CLI
https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
Step 4: Configure AWS
aws configure
Provide:
AWS Access Key
AWS Secret Key
Region
Output format
Step 5: Login to ECR
aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin your-account-id.dkr.ecr.ap-south-1.amazonaws.com
Step 6: Tag Image
docker tag node-app:latest your-account-id.dkr.ecr.ap-south-1.amazonaws.com/node-app:latest
Step 7: Push Image
docker push your-account-id.dkr.ecr.ap-south-1.amazonaws.com/node-app:latest
ECS Architecture
Client → Load Balancer → ECS Service → Task → Container
Cluster
A collection of compute resources.
Examples:
- EC2 Cluster
- Fargate Cluster
Task
A task is a running container.
It comes from:
Task Definition
Service
A service manages:
- Task count
- Failures
- Scaling
- Load balancing
Creating ECS Cluster
Go to:
AWS ECS → Create Cluster
Choose:
Fargate
or:
EC2 + Fargate
Create Task Definition
Go to:
Task Definitions → Create
Steps:
- Name the task
- Choose Fargate
- Add Docker image from ECR
- Configure CPU and memory
- Add port:
3000
Create ECS Service
Recommended configuration:
Capacity base = 0
Weight = 1
Desired tasks = 1
Load Balancer & Target Group
Traffic flow:
Load Balancer → Target Group → ECS Tasks
Open port:
80
for public access.
HTTPS Setup
Add listener:
HTTPS (443)
Attach:
- SSL Certificate
- Target Group
Allow:
443
in security groups.
Conclusion
AWS ECR and ECS make deploying containerized applications easier. By combining Docker, ECS, Fargate, Load Balancers, and Target Groups, developers can deploy scalable applications without manually managing servers.