Docker and Kubernetes in Modern App Development

Amanpreet SinghAmanpreet Singh
7 min read

Introduction

In the first week of January 2025, there was a tech meetup in my town, Dehradun, where I had the opportunity to give a talk on a very interesting topic - Docker and Kubernetes in modern app development. Since most participants were college students, I didn't delve too deeply. Instead, I provided a basic understanding of how Docker works, what Kubernetes is, and why these tools are essential in modern app development.

Here is what I presented at the meetup.

Challenges of Traditional Development

Some of the common challenges of Traditional Development are as follows:

  • Dependency Management Issues - Applications often fail to run in different environments due to conflicting dependencies or library versions. For example - A Python app runs on one machine but crashes on another due to a missing library.

  • Environment Configuration Problems - Setting up identical environments for development, testing, and production is tedious and error-prone.

  • Cross-Platform Development - Applications bound to specific operating systems or environments cannot easily move between on-premises and cloud infrastructure.

  • Scaling apps manually - Scaling traditional apps or managing complex microservices requires manual configuration or deploying more VMs, which is time-consuming and costly.

  • Inconsistent Delivery - Traditional methods lack standardization in packaging, making CI/CD pipelines complex and error-prone.

    Traditional deployment vs Virtualised Deployment vs Container Deployment

    Diagram comparing traditional applications, virtual machines, and containers. The traditional model includes apps directly on an operating system over hardware. The virtual machine model includes apps within virtual machines managed by a hypervisor. The container model has apps in containers managed by a container runtime, with all models running over hardware.

What is Docker?

Before I explain what Docker is, let me share a popular meme about how Docker came to be.

Funny meme image on "How Docker was born?"

  • Docker is an open-source platform that lets programmers create, launch, and operate apps inside lightweight, portable containers.

  • Regardless of the underlying infrastructure, Docker offers a standardized method for packaging, distributing, and managing programs, streamlining the software development process.

Key Components of Docker

  • Docker Engine: The core of Docker, responsible for building and running containers. It consists of three sub-components:

    • Docker Daemon (dockerd)

    • Rest API

    • Docker CLI

  • Docker Images: Docker images are read-only templates that contain the application code, runtime, libraries, and dependencies for creating a container.

  • Docker Containers: Lightweight instances of Docker images, running as isolated environments

  • Dockerfile: A text file with instructions to build a Docker Image.

  • Docker Hub: A cloud-based repository for storing and sharing Docker Images

  • Docker Compose: A tool for defining and managing multi-container Docker applications using a docker-compose.yml file

  • Docker Network: Allows containers to communicate with each other or external services.

  • Docker Volumes: A persistent storage mechanism to share data between containers or save data outside the container’s lifecycle.

These components & objects together make Docker a very powerful tool for developing, deploying, and running modern applications.

Diagram illustrating a layered architecture: app, framework, and libraries sit atop containers, Docker, operating system, and hardware, with the text "One daemon per host OS" at the bottom.

Docker Architecture

  • Docker follows a client-server architecture. Commands like docker run or docker build are executed on the Docker Client, which communicates with the Docker Daemon.

  • Docker Daemon and Docker Client can run on the same system, or the Docker Daemon can be connected remotely.

  • Docker Client and Docker Daemon communicate using a REST API.

    Diagram illustrating Docker architecture with three main sections: Client, Docker Host, and Registry. The Client uses commands like docker run, build, and pull to interact with the Docker daemon in the Docker Host. The Docker Host contains images, such as Python and Redis, and running containers. The Registry section stores images like NGINX and PostgreSQL, and includes Extensions and Plugins. Arrows depict interactions among components.

Key Benefits of Docker

  • Portability: Docker containers can run on any system that has Docker installed, whether it’s a developer’s laptop, a test server, or a cloud-based environment.

  • Efficiency: Containers share the host system’s kernel, which makes them more lightweight than traditional virtual machines, reducing resource overhead.

  • Rapid Deployment: With Docker, developers can quickly spin up new containers, enabling faster iterations and continuous integration/continuous deployment (CI/CD) practices.

  • Version Control: Docker images can be versioned, allowing teams to roll back to previous versions easily.

Alternatives to Docker

In 2023 Stack Overflow community ranked Docker the #1 most desired and #1 most-used developer tool. Check the survey link here. Even though Docker is widely used, there are some alternatives to Docker, as mentioned below.

  • Podman: A daemon-less container engine that works without root privileges

  • CRI-O: Designed for Kubernetes, providing lightweight and secure container runtime.

  • Rkt (Rocket): A container runtime focusing on security and composability.

  • OpenVZ: Provides OS-level virtualization similar to containers.

What is Kubernetes?

In today’s IT landscape, Docker and Kubernetes work together to build, deploy, and manage applications more effectively.

  • Kubernetes often abbreviated as K8s, is an open-source container orchestration platform developed by Google.

  • It automates the deployment, scaling and management of containerized applications.

  • With Kubernetes, enterprises can effectively manage containerized applications, scalability, and dependability in the real world.

Key Features of Kubernetes

  • Automatic Scaling: Kubernetes can automatically scale applications up or down based on demand, ensuring optimal resource utilization.

  • Load Balancing: It distributes network traffic evenly across containers, improving performance and reliability.

  • Self-Healing: Kubernetes automatically restarts failed containers, replaces them, and kills containers that don’t respond to health checks.

  • Service Discovery: K8s enables containers to find and communicate with each other seamlessly, simplifying inter-service communication.

Why are they essential for Modern App Development?

  • Docker and Kubernetes complement each other perfectly. Development with Docker & Deployment with Kubernetes is a match made in heaven 🤝.

  • Docker provides the means to package applications into containers, while Kubernetes provides a robust framework for managing those containers in production.

  • Simplifies CI/CD pipelines.

  • Scales microservices automatically. Ensures high availability with self-healing and load-balancing.

    Diagram showing Kubernetes cluster architecture. A Kubernetes logo is above, with an arrow pointing to stacked hosts below. Each host has Docker and Kubernetes Agent icons. Caption reads "Many Hosts per Cluster."

Practical Demo

I demoed them on the following topics

  • Created a simple Node JS App

  • Created a Dockerfile

      # Dockerfile
      WORKDIR /app
      COPY . .
      RUN yarn install --production
      CMD ["node", "src/index.js"]
      EXPOSE 3000
    
  • Build and run the Docker Container. Access the app via the browser

      # Build and access the app on browser via port 3000
      docker build -t demo-app .
      docker run -p 3000:3000 demo-app
    
  • Setup local Kubernetes Cluster (minikube)
    Follow this link to install Kubernetes on a local machine. https://minikube.sigs.k8s.io/docs/start/

  • Create Kubernetes manifests for Deployment and Service

      # Kubernetes Deployment file
      apiVersion: apps/v1
      kind: Deployment
      metadata:
        name: demo-app
      spec:
        replicas: 2
        selector:
          matchLabels:
            app: demo-app
        template:
          metadata:
            labels:
              app: demo-app
          spec:
            containers:
              - name: demo-app
                image: <Image pushed at Docker Hub>
                imagePullPolicy: Always
                ports:
                  - containerPort: 3000
                resources:
                  limits:
                    memory: "512Mi"
                    cpu: "500m"
                  requests:
                    memory: "256Mi"
                    cpu: "250m"
      ---
      # Kubernetes Service File
      apiVersion: v1
      kind: Service
      metadata:
        name: demo-app-service
      spec:
        selector:
          app: demo-app
        ports:
          - protocol: TCP
            port: 80
            targetPort: 3000
        type: NodePort
    
  • Deploy the app

      kubectl apply -f deployment.yaml
      kubectl apply -f service.yaml
    
  • Access the app via the service

Career Opportunities

  • Essential for roles in DevOps, Cloud, and Software Development.

  • Popular job titles: DevOps Engineer, Site Reliability Engineer (SRE), Cloud Engineer.

  • Skills: CI/CD, Cloud-native development, Infrastructure automation.

  • DevSecOps - DevOps together combined with Security practices.

Acknowledgements

  • Some of the images used in the article are taken from Docker's official website and ByteByteGo Newsletter.

References

Conclusion

That's it for today, and congratulations to everyone who has followed this article! You've successfully learned about the use of Docker and Kubernetes in Modern App Development. Go and implement them in your projects and make your life as a developer easy! 🎉

I hope you have learned something new, just as I did. If you enjoyed this article, please like and share it. Also, follow me to read more exciting articles. You can check out my social links here.

1
Subscribe to my newsletter

Read articles from Amanpreet Singh directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Amanpreet Singh
Amanpreet Singh

Passionate developer and software crafter with a passion for problem-solving. Always learning and growing in the field. Currently looking for a job or freelance gig. Need a software consultant? I am your guy! With experience in websites, applications, and cloud services, I can provide top-notch solutions for your business needs. Let's work together to take your tech game to the next level. Contact me today for part-time consulting opportunities