"You mean I can run containers on AWS without managing servers?"
Yes. Thatβs the magic of ECS with Fargate β AWS runs the servers, and you just run your containers. π
In this beginner-friendly guide, weβll walk through deploying a Dockerized app to Amazon ECS using Fargate, step by step, using plain English, code snippets, and real-world metaphors.
Letβs go from local Docker image to live app on AWS β in under 20 minutes.
π§ Why ECS + Fargate?
ECS (Elastic Container Service) is AWSβs managed container orchestration.
Fargate is the serverless engine behind it β you donβt manage EC2s, VMs, or clusters.
Think of ECS as a pizza restaurant.
- With EC2 launch type: you bring your own oven.
- With Fargate: AWS brings the oven. You just bring the ingredients (containers).
π§° What Youβll Need
- AWS account
- Docker installed
- A simple app (e.g., Node.js, Python, HTML)
- AWS CLI & ECS CLI installed (optional but helpful)
π§ͺ Step-by-Step: Deploy Your App with ECS + Fargate
1. Dockerize Your App
Here's a basic Dockerfile
for a Node.js app:
FROM node:18 WORKDIR /app COPY package*.json ./ RUN npm install COPY . . CMD ["node", "index.js"]
Build and tag it:
docker build -t my-app .
2. Push to Amazon ECR (Elastic Container Registry)
Create an ECR repo:
aws ecr create-repository --repository-name my-app-repo
Authenticate Docker:
aws ecr get-login-password | docker login --username AWS --password-stdin <your-account-id>.dkr.ecr.<region>.amazonaws.com
Tag and push:
docker tag my-app:latest <your-ecr-url>/my-app-repo:latest docker push <your-ecr-url>/my-app-repo:latest
3. Create ECS Cluster
Go to ECS β Create Cluster β Choose "Networking only (Fargate)"
Name it my-app-cluster
4. Define Task Definition
- Go to ECS β Task Definitions β Create New
- Choose Fargate
-
Add container with:
- Image:
your-ecr-url/my-app-repo:latest
- Port mappings: 80 (or whatever your app uses)
- Image:
Set CPU:
256
and Memory:512
(or as needed)
5. Create Service
- ECS β Clusters β
my-app-cluster
- Click Create Service
- Launch type: Fargate
- Task Definition: the one you just created
- Desired tasks: 1
- Select a VPC and subnets
- Enable public IP if hosting a public web app
- Create a new Security Group allowing port 80
Click "Create Service" β wait for it to spin up βοΈ
6. Access Your App!
Once the task is running:
- Go to EC2 β Network Interfaces
- Find the ENI attached to your task
- Copy its public IP
Open in browser:
http://<public-ip>
Boom π₯! Your containerized app is now live.
π§ Why Devs Love ECS + Fargate
- β No servers to manage
- β Pay only for what you use
- β Scales easily
- β Deep AWS integration (CloudWatch, IAM, etc.)
- β Great for microservices
π Bonus: Add HTTPS with Load Balancer + ACM
Want a custom domain and SSL?
- Use Application Load Balancer
- Add HTTPS listener
- Use AWS Certificate Manager (ACM) to create free SSL certs
π¦ Final Thoughts + Whatβs Next
You just deployed a production-grade app using Docker + AWS β no EC2s, no pain.
Next steps?
- Add autoscaling
- Use CodePipeline for CI/CD
- Add CloudWatch monitoring
π¬ Your Turn: Did You Deploy It?
Was this guide helpful?
Are you stuck on a step?
Got your app running?
π Drop your questions, success stories, or URLs in the comments.
If this made ECS + Fargate feel easier β hit β€οΈ and share with a dev friend who's drowning in EC2 setup hell.
Letβs Docker smarter, not harder. π§‘
Top comments (1)
This guide is gold. especially the pizza metaphor π. ECS + Fargate always felt intimidating, but breaking it down like this makes it way more approachable. Got my app running in under 30 minutes. Thanks for making serverless feel less scary!