In the previous post, we built and ran a Python app in Docker.
Now let’s take it to the cloud — using AWS ECS (Elastic Container Service) with Fargate, which lets you run containers without managing servers.
By the end of this post, your Docker app will be live on AWS, accessible via a public URL.
Step 1 — Install the Required Tools
Before deploying, you need a few things installed on your machine:
✅ An AWS Account — https://aws.amazon.com
✅ Docker — make sure it’s installed and running
✅ AWS CLI — command-line access to AWS
✅ AWS Copilot CLI — simplifies ECS setup and deployment
To install them:
macOS:
brew install awscli
brew install aws/tap/copilot-cli
Linux:
sudo apt install awscli -y
curl -Lo copilot https://github.com/aws/copilot-cli/releases/latest/download/copilot-linux
chmod +x copilot
sudo mv copilot /usr/local/bin/copilot
Then configure your AWS account:
aws configure
This command asks for:
- Your AWS Access Key ID
- Secret Access Key
- Default region name (e.g.
us-east-1) - Output format (
jsonis fine)
Once done, AWS CLI is ready to talk to your account.
Step 2 — Build Your Docker Image
Make sure your project has a working Dockerfile (see the previous post if you don’t).
Then build your image:
docker build -t my-flask-app .
Run it locally to confirm it works:
docker run -p 5000:5000 my-flask-app
If you can visit http://localhost:5000 and see your app, you’re good to go.
Step 3 — Push Your Image to Amazon ECR
ECR (Elastic Container Registry) is AWS’s private Docker registry — it’s where you’ll store your image before ECS can deploy it.
Create a repository:
aws ecr create-repository --repository-name my-flask-appFind your AWS account ID:
aws sts get-caller-identity --query Account --output textAuthenticate Docker with ECR:
aws ecr get-login-password | docker login \
--username AWS \
--password-stdin <ACCOUNT_ID>.dkr.ecr.<REGION>.amazonaws.com
Tag and push your image:
docker tag my-flask-app <ACCOUNT_ID>.dkr.ecr.<REGION>.amazonaws.com/my-flask-app:latest
docker push <ACCOUNT_ID>.dkr.ecr.<REGION>.amazonaws.com/my-flask-app:latestNow your image lives in AWS — ready to be deployed 🚀
Step 4 — Deploy with AWS Copilot
AWS Copilot makes deploying to ECS super easy — no manual setup required.
Initialize your app:
copilot init
When prompted:
- App name:
my-flask-app - Workload type:
Load Balanced Web Service - Dockerfile: select your local Dockerfile
- Port:
5000
Then deploy:
copilot deploy
Copilot will:
- Create an ECS cluster
- Set up Fargate (serverless containers)
- Create a load balancer
- Deploy your Docker image
Once finished, it prints a public URL like:
https://my-flask-app.xxxxx.amazonaws.com
Open that link — your Flask app is live on AWS! 🎉
Step 5 — Redeploy Updates
When you make changes to your app, redeploy by:
docker build -t my-flask-app .
docker push <ECR_URL>/my-flask-app:latest
copilot deploy
ECS automatically updates your container with zero downtime.
Step 6 — Clean Up (Optional)
When you’re done testing, you can remove all resources to avoid charges:
copilot app delete
This removes the ECS cluster, load balancer, and repository.
Recap
Here’s the complete Docker → AWS ECS workflow:
- Build your Docker image
- Push it to Amazon ECR
- Deploy with AWS Copilot
- Get your public URL
- Redeploy anytime you update your app
That’s it — your Docker app now runs in the cloud, serverlessly, with almost zero setup.