Skip to content Skip to sidebar Skip to footer

Docker Bootcamp: Conquer Docker with Real-World Projects

Docker Bootcamp: Conquer Docker with Real-World Projects

Docker Bootcamp: Conquer Docker with Real-World Projects. Containerize Apps, Manage Microservices, and Deploy to the Cloud with Docker!

Enroll Now

Docker has revolutionized the way we develop, ship, and run applications. By encapsulating applications into containers, Docker provides a consistent environment that can be run anywhere, from a developer's laptop to large-scale production systems. This bootcamp is designed to take you from Docker novice to proficient user through hands-on projects that mirror real-world scenarios.

Understanding Docker Fundamentals

Before diving into projects, it’s essential to grasp Docker’s core concepts. Docker is based on containerization, which means packaging an application and its dependencies into a container. These containers are lightweight, portable, and ensure consistency across different environments.

Key Concepts

  1. Images: Immutable templates that define a container’s contents. They are built from a Dockerfile and can be shared via Docker Hub or private repositories.
  2. Containers: Running instances of Docker images. Containers can be started, stopped, and deleted without affecting the image.
  3. Dockerfile: A script containing a series of instructions on how to build a Docker image.
  4. Docker Compose: A tool for defining and running multi-container Docker applications. It uses a YAML file to configure application services.

Project 1: Simple Web Application


Create a Docker container for a simple web application. This project will introduce you to Dockerfile creation, image building, and container management.


  1. Set Up the Application: Use a basic web application written in Node.js. Here’s a simple app.js:

    const express = require('express'); const app = express(); const port = 3000; app.get('/', (req, res) => { res.send('Hello, Docker!'); }); app.listen(port, () => { console.log(`App running at http://localhost:${port}`); });
  2. Create a Dockerfile: Write a Dockerfile to containerize this application.

    # Use the official Node.js image FROM node:14 # Create a directory for the app WORKDIR /app # Copy the application code COPY . . # Install dependencies RUN npm install # Expose the port EXPOSE 3000 # Command to run the application CMD ["node", "app.js"]
  3. Build the Image: Run the following command to build the Docker image.

    docker build -t my-node-app .
  4. Run the Container: Start the container from the image.

    docker run -p 3000:3000 my-node-app
  5. Access the Application: Open a browser and navigate to http://localhost:3000 to see the running application.

Project 2: Multi-Container Application with Docker Compose


Deploy a multi-container application consisting of a web server and a database using Docker Compose.


  1. Set Up the Web Application: Extend the previous Node.js application to interact with a PostgreSQL database. Update app.js:

    const express = require('express'); const { Pool } = require('pg'); const app = express(); const port = 3000; const pool = new Pool({ user: 'user', host: 'db', database: 'testdb', password: 'password', port: 5432, }); app.get('/', async (req, res) => { const client = await pool.connect(); const result = await client.query('SELECT NOW()'); client.release(); res.send(`Current time: ${result.rows[0].now}`); }); app.listen(port, () => { console.log(`App running at http://localhost:${port}`); });
  2. Create a Dockerfile: Use the same Dockerfile as in Project 1.

  3. Define Services with Docker Compose: Create a docker-compose.yml file.

    version: '3.8' services: web: build: . ports: - "3000:3000" depends_on: - db db: image: postgres:13 environment: POSTGRES_USER: user POSTGRES_PASSWORD: password POSTGRES_DB: testdb
  4. Run Docker Compose: Start the application using Docker Compose.

    docker-compose up
  5. Verify the Setup: Navigate to http://localhost:3000 to see the current time fetched from the database.

Project 3: CI/CD Pipeline with Docker


Integrate Docker into a CI/CD pipeline to automate the build, test, and deployment processes using GitHub Actions.


  1. Prepare the Repository: Ensure your code is in a GitHub repository with the Dockerfile and docker-compose.yml.

  2. Set Up GitHub Actions: Create a workflow file in .github/workflows/docker.yml.

    name: CI/CD Pipeline on: push: branches: [ main ] jobs: build: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - name: Log in to Docker Hub uses: docker/login-action@v1 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Build and push Docker image run: | docker build -t my-node-app:latest . docker tag my-node-app:latest ${{ secrets.DOCKER_USERNAME }}/my-node-app:latest docker push ${{ secrets.DOCKER_USERNAME }}/my-node-app:latest - name: Deploy to Docker Hub run: | docker-compose down docker-compose up -d
  3. Configure Secrets: Add DOCKER_USERNAME and DOCKER_PASSWORD to the GitHub repository secrets.

  4. Push Changes: Push the code to the main branch and observe the workflow execution on GitHub Actions.

Project 4: Orchestrating Containers with Kubernetes


Deploy a Dockerized application on a Kubernetes cluster for better scalability and management.


  1. Install Kubernetes: Set up a local Kubernetes cluster using Minikube or use a managed Kubernetes service.

  2. Create Kubernetes Manifests: Define the Kubernetes resources in YAML files.

    • Deployment: deployment.yaml

      apiVersion: apps/v1 kind: Deployment metadata: name: web spec: replicas: 3 selector: matchLabels: app: web template: metadata: labels: app: web spec: containers: - name: web image: my-node-app:latest ports: - containerPort: 3000
    • Service: service.yaml

      apiVersion: v1 kind: Service metadata: name: web spec: type: NodePort ports: - port: 3000 nodePort: 30000 selector: app: web
  3. Apply Manifests: Deploy the application to the Kubernetes cluster.

    kubectl apply -f deployment.yaml kubectl apply -f service.yaml
  4. Access the Application: Get the Minikube IP and access the application via http://<minikube-ip>:30000.


This Docker Bootcamp has guided you through creating, managing, and deploying containerized applications using Docker. By working on these real-world projects, you’ve gained practical experience that prepares you for deploying applications in diverse environments, ensuring consistency, scalability, and efficiency. Docker's ability to integrate with CI/CD pipelines and orchestrate with Kubernetes further solidifies its role in modern DevOps practices. Happy Dockering!

Online Course CoupoNED based Analytics Education Company and aims at Bringing Together the analytics companies and interested Learners.