logo
Post preview

Docker is Awesome

Author

Lucas Narloch

8/26/2025

Category: backend

Introduction

Docker is a container service that allow developers to run isolated and fully predictable applications, it is widely in professional backend systems.

Problems it resolves

You’ve probably heard the phrase “but it works on my machine” at least once. This is a common issue when applications rely on local environments, where differences in configuration can lead to unexpected bugs.

Docker solves this problem by allowing the creation of isolated environments called containers. Each container encapsulates all the dependencies, configurations, and runtime needed to run the application. These configurations are defined in a single file called a Dockerfile, which can be built and executed consistently across any machine.

This ensures:

  • Environment consistency – same behavior in development, staging, and production.
  • Portability – containers can run anywhere: locally, on servers, or in the cloud.
  • Simplified onboarding – new developers only need Docker installed to get the project running.

Basic Concepts

Container

A container is a lightweight, standalone, and executable package that includes everything needed to run a piece of software: the application code, runtime, libraries, and system tools. Unlike traditional virtual machines, containers share the host system’s kernel but remain isolated from other processes, ensuring consistent behavior across environments.

Key characteristics:

  • Isolation: Each container runs independently, avoiding conflicts with other applications.
  • Portability: Containers can run consistently on any machine with a container runtime (like Docker).
  • Efficiency: Containers are lightweight and start quickly compared to full virtual machines.

Image

A Docker image is a read-only template used to create containers. It contains the application code, dependencies, and the filesystem snapshot. Images can be versioned, shared, and reused to ensure consistency across deployments.

Key characteristics:

  • Immutable: Once built, the image does not change.
  • Layered: Images are built in layers, making them efficient and easy to cache.
  • Reusable: The same image can be deployed in multiple environments.

Dockerfile

A Dockerfile is a text file that contains a set of instructions to build a Docker image. It defines the base image, dependencies, configurations, and commands that should run when the container starts.

Common instructions:

  • FROM: Specifies the base image.
  • RUN: Executes commands to install dependencies.
  • COPY / ADD: Copies files into the image.
  • CMD / ENTRYPOINT: Defines the default command for the container.

Volume

A volume is a mechanism to persist data outside of a container’s lifecycle. Volumes allow containers to store and share data even if the container is deleted or recreated.

Key characteristics:

  • Persistence: Data survives container deletion.
  • Sharing: Multiple containers can access the same volume.
  • Isolation: Volume data is isolated from the host filesystem unless explicitly mounted.

Network

Docker containers can communicate with each other and with the outside world through Docker networks. Networks provide isolation, control, and connectivity between containers.

Types of networks:

  • Bridge: Default network type for standalone containers.
  • Host: Shares the host’s network stack.
  • Overlay: Connects containers across multiple Docker hosts.
  • None: No networking for the container.

Registry

A Docker registry is a storage and distribution system for Docker images. The most common public registry is Docker Hub, but private registries can also be used.

Key points:

  • Storage: Stores Docker images in a central location.
  • Versioning: Keeps track of different image versions (tags).
  • Distribution: Enables sharing images across teams and environments.

Docker Compose

Docker Compose is a tool that allows you to define and manage multi-container Docker applications using a single YAML file, usually called docker-compose.yml. With Compose, you can configure services, networks, and volumes in one place and start everything with a single command.

Key Concepts

  • Service: A service represents a containerized application. You can define multiple services in one Compose file, each with its own image, build instructions, environment variables, and ports.
  • Network: Compose automatically creates a default network, allowing services to communicate with each other by name.
  • Volume: You can define named volumes for data persistence across container lifecycles.

Example docker-compose.yml

version: "3.9"

services:
  web:
    build: ./web
    ports:
      - "5000:5000"
    environment:
      - FLASK_ENV=development
    volumes:
      - web_data:/app/data

  redis:
    image: "redis:alpine"
    ports:
      - "6379:6379"

volumes:
  web_data:

Conclusion

Docker has transformed the way developers build, ship, and run applications. By using containers, developers can ensure consistency across environments, simplify dependency management, and accelerate deployment processes.

Tools like Docker Compose further enhance this workflow by allowing teams to define and orchestrate multi-container applications with ease. Together, Docker and Compose provide a robust framework for building scalable, portable, and maintainable applications.

Adopting Docker in your development process not only reduces the “it works on my machine” problem but also improves collaboration, testing, and deployment efficiency, making it an essential tool in modern software development.