CHAPTER 19
Beginner
Real-World Docker Projects
Updated: May 15, 2026
30 min read
# CHAPTER 19
Real-World Docker Projects
1. Introduction
Employers do not hire candidates because they have read a book on Docker; they hire candidates who can prove they have synthesized Docker commands into working, production-grade applications. A strong GitHub portfolio is your greatest asset in a DevOps or Backend Engineering interview. In this chapter, we transition from theory to practice by outlining five progressive portfolio projects designed to demonstrate your mastery of containerization.2. Learning Objectives
By the end of this chapter, you will be able to:- Synthesize multiple Docker concepts (Images, Networks, Volumes) into cohesive architectures.
- Build a progressive Docker portfolio to showcase to employers.
- Understand the architectural diagrams of common enterprise workloads.
-
Translate real-world business requirements into
docker-compose.ymlconfigurations.
3. Project 1: The Dockerized Static Portfolio (Beginner)
The Goal: Prove you understand fundamental image creation, web serving, and port mapping. The Architecture:- 1. Frontend: Write a personal resume or portfolio using HTML, CSS, and basic JavaScript.
-
2.
The Blueprint: Write a custom
Dockerfilethat utilizesnginx:alpineas the base image.
-
3.
The Build: Copy your static files into the
/usr/share/nginx/htmldirectory during the build process.
-
4.
Publishing: Build the image using your Docker Hub namespace (
username/portfolio:v1), log in to Docker CLI, and push it to a public repository.
-
5.
The Proof: Include a command in your
README.mdshowing employers how they can run your resume on their own machine with a single line:docker run -p 8080:80 username/portfolio:v1.
4. Project 2: The Containerized Node.js API (Intermediate)
The Goal: Demonstrate you can package a dynamic, server-side language, handle dependencies, and secure the container by running as a non-root user. The Architecture:-
1.
The App: Write a simple Node.js Express API that returns a JSON list of users (e.g.,
[{"id": 1, "name": "Alice"}]).
-
2.
The Blueprint: Write a
Dockerfileutilizingnode:18-alpine.
-
3.
Security: Create a
nodeuser group and switch to it (USER node) before theCMDinstruction to ensure the API does not run as root.
-
4.
Optimization: Copy the
package.jsonfile and runnpm install*before* copying the rest of your application code. This proves you understand Docker Layer Caching!
-
5.
The Proof: Provide a
docker-compose.ymlthat builds the image locally and exposes port 3000.
5. Project 3: The 3-Tier PHP & MySQL Stack (Intermediate)
The Goal: Prove you can orchestrate multiple containers, isolate networks, and persist data permanently. The Architecture:-
1.
The Orchestration: Create a
docker-compose.ymlfile defining three services:web(Nginx),php(PHP-FPM), anddb(MySQL).
-
2.
Networking: Place all three services on a custom
backend-netDocker network. Only publish (-p) Port 80 on the Nginx container. The PHP and MySQL containers must remain completely hidden from the host machine.
-
3.
Data Persistence: Attach a Named Volume to the MySQL container (
/var/lib/mysql) to ensure data survives container destruction.
-
4.
Initialization: Map a
schema.sqlfile to the MySQL auto-initialization directory to automatically create a "Users" table on startup.
-
5.
The Code: Write a simple PHP script that connects to the MySQL container using the
dbhostname, inserts a user, and displays the database contents on the screen.
6. Project 4: The Secure Nginx Reverse Proxy (Advanced)
The Goal: Demonstrate enterprise routing, separating public-facing traffic cops from hidden backend microservices. The Architecture:-
1.
Backend Services: Deploy two simple Node.js or Python APIs. Service A runs on port 3001, Service B runs on port 3002. Neither service should have published ports (
-p).
-
2.
The Proxy: Deploy an Nginx container. Publish Port 80 (
-p 80:80).
-
3.
The Configuration: Write a custom
nginx.conffile and mount it into the Nginx container as a read-only Bind Mount (:ro).
-
4.
The Routing Rules: Configure the
nginx.confso that if a user visitshttp://localhost/api1, the traffic is secretly proxied to Service A. If they visithttp://localhost/api2, the traffic is proxied to Service B.
- 5. The Proof: This proves you understand how to protect backend applications from direct internet exposure using a secure, single point of entry.
7. Project 5: The Automated CI/CD Deployment Pipeline (Advanced)
The Goal: Prove you understand modern DevOps automation. Never manually typedocker build again.
The Architecture:
- 1. The Repository: Push your Node.js or PHP application (from Project 2 or 3) to a GitHub repository.
-
2.
The Pipeline: Write a GitHub Actions YAML workflow (
.github/workflows/deploy.yml).
-
3.
The Trigger: Configure the workflow to trigger automatically whenever code is pushed to the
mainbranch.
-
4.
The Build Step: Configure the workflow to use a temporary Ubuntu runner to check out your code and execute
docker build.
-
5.
The Security Step: Add a pipeline step utilizing
docker scoutto scan your newly built image for critical CVE vulnerabilities. If a vulnerability is found, the pipeline must fail.
-
6.
The Publish Step: If the scan passes, the pipeline securely logs into Docker Hub using encrypted GitHub Secrets and executes
docker push.
- 7. The Proof: Your GitHub repository will display a green "Passing" badge, proving to employers that your code is rigorously tested and automatically packaged.
8. How to Present Your Projects
An undocumented project is a useless project.-
The README: Every GitHub repository must contain a flawless
README.md.
- The "Why": Do not just list the commands to run the code. Explain *why* you made architectural decisions. *"I utilized Alpine Linux to reduce the attack surface. I isolated the database on an internal Docker network to prevent port scanning."*
- Visuals: Use a free tool like Draw.io to sketch out the Container, Volume, and Network boundaries and embed the image in the README. Visual communication is a senior engineering skill.