What is Docker

Python courses 

What is Docker




Docker is a tool that lets you package an application together with everything it needs to run and then run it consistently anywhere.

The simplest mental model is:

Docker = a standardized box for your application.

The problem Docker solves

Imagine you build a Python application on your laptop:

Python 3.12
pandas 2.x
requests
PostgreSQL client
some configuration

It works perfectly.

Then you give it to someone else, and they get:

"It doesn't work on my machine."

Maybe they have Python 3.10, a different library version, or a missing dependency.

Docker helps solve this by packaging the environment:

┌─────────────────────────────┐
│       Docker Container      │
│                             │
│   Your application          │
│   Python                    │
│   Libraries                 │
│   Configuration             │
│                             │
└─────────────────────────────┘

You can then run that container on another machine with much less environment mismatch.


Docker vs a Virtual Machine

They're related, but not the same.

A traditional virtual machine might look like:

Computer
│
├── Operating System
│
├── Virtual Machine
│   ├── Guest OS
│   ├── Application
│   └── Dependencies
│
└── Virtual Machine
    ├── Guest OS
    └── Application

Docker containers typically look more like:

Computer
│
├── Operating System
│
├── Docker
│
├── Container
│   ├── Application
│   └── Dependencies
│
└── Container
    ├── Application
    └── Dependencies

Containers share the host OS kernel, so they're generally lighter and faster to start than full VMs.


The 3 Docker concepts you should know

1. Image

An image is a packaged template for a container.

For example:

Python image
    +
Your code
    +
requirements.txt
    ↓
Your Docker image

You can think of an image as a blueprint.

2. Container

A container is a running instance of an image.

Image
  ↓
Container
  ↓
Running application

You can create multiple containers from the same image.

3. Dockerfile

A Dockerfile tells Docker how to build your image.

For example:

FROM python:3.12

WORKDIR /app

COPY requirements.txt .
RUN pip install -r requirements.txt

COPY . .

CMD ["python", "app.py"]

This basically says:

  1. Start with Python 3.12

  2. Create /app

  3. Install the dependencies

  4. Copy the application

  5. Run app.py


How Docker fits with Airflow and Spark

This is where things get interesting for data engineering.

You could have:

                 Docker
                   │
       ┌───────────┼───────────┐
       ↓           ↓           ↓
    Airflow      Spark      PostgreSQL
       │           │
       └───────────┼───────────┘
                   ↓
                 Data

For example, you might run Airflow inside Docker containers:

Docker
│
├── Airflow scheduler
├── Airflow webserver
├── PostgreSQL
└── Your data pipeline

And Airflow could then trigger a Spark job:

Airflow
   │
   │ triggers
   ↓
Spark
   │
   │ processes
   ↓
Large dataset

So these technologies have different jobs:

TechnologyMain job
DockerPackage and run applications consistently
AirflowSchedule and orchestrate workflows
SparkProcess large datasets
PostgreSQLStore/query relational data

The easiest analogy

Imagine a restaurant:

  • Docker = the kitchen setup packaged so it can be reproduced elsewhere

  • Airflow = the manager deciding what gets done and when

  • Spark = the team doing large-scale food preparation

  • PostgreSQL = the storage/database keeping the ingredients and records

If you're learning these for data engineering, I'd learn them in roughly this order:

Python → SQL → Linux → Git → Docker → Spark → Airflow → Cloud (AWS/Azure/GCP).

Python courses 


Python courses 


Comments

Popular posts from this blog

Delete vs Truncate in MySQL and MS SQL Server

Building Cross-Platform JavaFX Apps with Gluon

Companies and real-world applications using JavaFX