A complete step-by-step tutorial on how to deploy a Python Flask App on an AWS EC2 instance using Docker, aimed at beginners in DevOps and Cloud Computing.
π₯ Watch the Full Video Tutorial Here:
Watch on YouTube
- Launch and configure an AWS EC2 instance
- Connect to EC2 using SSH in WSL (Ubuntu on Windows)
- Install Docker on EC2 instance
- Clone a simple Flask app with
app.py
,run.py
, andreq.txt
- Write a custom
Dockerfile
- Build and run a Docker image
- Expose the Flask app on the browser using public IP
- AWS EC2 (Ubuntu)
- Docker & Dockerfile
- Python 3.7
- Flask
- Git
- WSL (Ubuntu on Windows)
FROM python:3.7
WORKDIR /app
COPY . .
RUN pip install -r req.txt
ENTRYPOINT ["python"]
CMD ["run.py"]
sudo apt update
sudo apt install docker.io
git clone <your-flask-repo-url>
docker build -t flask-app .
docker run -d -p 80:80 flask-app
Once deployed, access your app using:
http://<your-ec2-public-ip>