Skip to main content

Command Palette

Search for a command to run...

Day 2: Building My First Flask App with Docker – DevOps Journey Begins

Updated
β€’2 min read
S

πŸš€ Aspiring Cloud & DevOps Engineer | AWS Free Tier User | Learning by Building

Hi, I’m Sukaran Mahajan β€” I am working as System Administrator and currently on a focused journey to become job-ready in AWS Cloud, DevOps, and Infrastructure automation. With a growing foundation in Linux, Git, Docker, and Terraform, I’m documenting everything I learn to help others and strengthen my understanding.

πŸ’‘ Currently Learning: β€’ AWS (EC2, S3, IAM, VPC, Lambda) β€’ Docker, Terraform & Ansible β€’ CI/CD tools (GitHub Actions, Jenkins) β€’ Kubernetes basics

πŸ›  Hands-on Projects: β€’ Flask + Docker App Deployment β€’ Terraform-based AWS Infrastructure β€’ EC2 SSH automation & S3 access control

πŸ“ I also write beginner-friendly technical blogs on Hashnode: πŸ”— https://devopswithsukaran.hashnode.dev

πŸ’Ό Open to internships, DevOps/cloud roles, and collaborative projects.

Let’s connect and grow in tech together! πŸ”—

---

πŸ“ Title:

Day 2: Building My First Flask App with Docker – DevOps Journey Begins

---

🧠 Description (For Hashnode SEO):

Today I containerized my first Python Flask application using Docker. I learned how to write a Dockerfile, run a container, and understand the importance of __name__ in Flask. Follow along my DevOps journey from scratch!

---

πŸ“„ Blog Content:

# πŸš€ Day 2: Building My First Flask App with Docker

Hey everyone! πŸ‘‹

Welcome to **Day 2** of my DevOps learning journey. I'm sharing everything I learn each day as I move toward my goal of becoming a DevOps engineer. Today, I built my first Flask application and containerized it using Docker.

---

## πŸ”§ What I Did Today

I created a small Flask web application, then used Docker to containerize and run it. This is my first step toward understanding how apps run in isolated environments β€” something essential in DevOps.

---

## πŸ“ Project Structure

flask-docker-app/ β”œβ”€β”€ app.py β”œβ”€β”€ requirements.txt └── Dockerfile

---

## 🧠 app.py Code

```python

from flask import Flask

app = Flask(__name__)

@app.route('/')

def home():

return "πŸš€ Hello from Flask inside Docker on EC2!"

if __name__ == '__main__':

app.run(host='0.0.0.0', port=5000)

\> I learned the difference between __name__ and --name--, and why it's important to write it properly.

---

πŸ“¦ Dockerfile

FROM python:3.9-slim

WORKDIR /app

COPY requirements.txt requirements.txt

COPY app.py app.py

RUN pip install --no-cache-dir -r requirements.txt

EXPOSE 5000

CMD ["python", "app.py"]

---

βš™οΈ How I Built and Ran the Image

docker build -t flask-py .

docker run -p 5000:5000 flask-py

Then I opened my browser and visited:

http://localhost:5000

βœ… My app worked!

---

πŸ’‘ Key Learnings

Flask basics and routing

Difference between Flask(__name__) vs Flask(--name--)

Docker basics: image, container, ports

How to write a Dockerfile

---

πŸ”œ Next Steps (Tomorrow)

Deploy this Docker app on AWS EC2

Learn to SSH into EC2 and run containers

Link GitHub and LinkedIn to showcase the project

---

πŸ’¬ Final Thoughts

Even though I come from a system administration background, learning Docker and Flask felt very exciting. I now understand how containers work and why they’re so useful in DevOps pipelines.

Stay tuned for more updates. If you’re on a similar path, let’s connect on LinkedIn!

#DevOps #Docker #Flask #AWS #100DaysOfCloud #HashnodeBlog

---

More from this blog

DevOpsWithSukran

10 posts