How to Deploy a Dockerized App on ECS (with Fargate) 🚢🔥

Yash SonawaneYash Sonawane
3 min read

"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)

  • 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. 🧡

0
Subscribe to my newsletter

Read articles from Yash Sonawane directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Yash Sonawane
Yash Sonawane

DevOps & Cloud Engineer | AWS, Docker, K8s, CI/CD Writing beginner-friendly blogs to simplify DevOps for everyone.