Jul 6, 2025 2 min read

How to Build a CI/CD Pipeline Using Jenkins and Docker (Step-by-Step Guide)

How to Build a CI/CD Pipeline Using Jenkins and Docker (Step-by-Step Guide)

Building a Simple Jenkins CI/CD Pipeline for a Dockerized Flask App

I recently built my first real-world CI/CD pipeline using Jenkins, Docker, and Flask — and I want to share the journey with you.

What I Wanted to Achieve

Automatically build, test, and deploy a Flask app every time I push code

How I Did It

  1. Set up the project Created a basic Flask app and wrote tests using pytest. I also added a requirements.txt file listing dependencies.

  2. Created a Jenkinsfile pipeline Defined stages:

  3. Clone the GitHub repo

  4. Install dependencies (pip install -r requirements.txt)
  5. Run tests (pytest)
  6. Build Docker image
  7. Run Docker container

  8. Installed Jenkins and Docker on my RHEL machine Made sure Jenkins can run Docker commands (added Jenkins user to Docker group).

  9. Pushed the code to GitHub Hosted the repo publicly to make integration easier.

  10. Connected Jenkins with GitHub using Webhooks and Ngrok Since Jenkins runs locally, I used ngrok to expose my localhost to the internet. This allowed GitHub to notify Jenkins instantly when I push changes.

  11. Configured Jenkins job to trigger on webhook events Enabled GitHub hook trigger for GITScm polling in Jenkins.

Challenges I Faced

The Outcome

Now, every time I push code to GitHub:

Why This Matters

This project taught me how real CI/CD pipelines work in practice, and gave me a solid foundation to build more advanced DevOps skills. If you're starting your DevOps journey, I recommend building a similar pipeline. It covers all core concepts and tools without being overwhelming.

Code Repo: here

Liked this? Get more in your inbox.

One short email when I publish. AWS, AI, and founder notes — no spam, unsubscribe in one click.

By JOY 11 months ago

// Read next

How to Host Your Static Website on AWS S3 and CloudFront (Step-by-Step Guide)

# 🌍 Day 1 — Host a Static Website on AWS (S3 + CloudFront) When I started my …

AWS EventBridge Explained: The Ultimate Q&A Guide for Developers (with Real-Life Examples)

# 🧩 AWS EventBridge Explained: The Ultimate Q&A Guide for Developers (with Real-Life Examples) ## 🧠 1. What …

AWS API Gateway: A Practical, Step-by-Step Guide

## 🔗 What Is API Gateway? AWS API Gateway is the **entry point** for your backend APIs. It …