๐Ÿ“ Docker

What Is Docker and Why You Need It

P
Author
PyLand Team
๐Ÿ“…
Published
08.05.2026
โฑ๏ธ
Reading time
2 min
๐Ÿ‘๏ธ
Views
323
๐ŸŒฑ
Level
Beginner

Docker solves one of the most common problems in software development: “It works on my machine, but not on the server.”

The Root of the Problem

When you run code locally, it runs in a specific environment: a particular Python version, specific libraries, a specific OS. The server has a different Python version, different package versions, a different OS. The code breaks even if you didn’t touch it.

Classic scenario: you wrote an app on Python 3.11, your colleague has Python 3.9, CI uses 3.10, production runs 3.8. match doesn’t work somewhere, a package is missing somewhere else, systemd blocks a port somewhere. Every environment is its own source of surprises.

What Is Docker

Docker is a tool for running applications in containers. A container holds everything it needs: code, runtime, libraries, system dependencies. The same package runs identically everywhere โ€” on your Mac, your colleague’s server, and in the cloud.

Analogy: a shipping container. Everything is packed inside. Ship it by sea, rail, or truck โ€” the contents don’t change.

Image vs Container

  • Image โ€” an immutable template. Like a class in OOP or an installation disk.
  • Container โ€” a running instance of an image. Like an object instantiated from a class.

One image โ†’ many containers. Delete a container โ€” the image stays.

Container vs Virtual Machine

Virtual Machine Docker Container
What it isolates An entire computer (kernel, memory, disk) Only processes
Size Gigabytes Megabytes
Startup time Minutes Seconds
Uses host kernel No Yes

A container doesn’t emulate hardware โ€” it uses the host kernel and isolates only processes. That’s why it’s faster and lighter.

In short:
- A VM runs a full OS with its own kernel โ€” maximum isolation, but costs gigabytes of RAM and minutes to start
- Docker uses the host kernel and isolates only the process space โ€” lightweight, fast, sufficient for most tasks
- VMs are needed when you require a different OS (a Windows container on a Linux host); Docker is for isolating an application

Docker vs virtualenv

virtualenv only isolates Python libraries. Docker isolates everything: the Python version, system packages, ports, the filesystem. Docker works with more than just Python.

A Simple Dockerfile

Dockerfile is a text file with instructions for building an image:

# Use the official Python image
FROM python:3.11-slim

# Working directory inside the container
WORKDIR /app

# Copy dependencies and install them
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy all source code
COPY . .

# Command to start the application
CMD ["python", "app.py"]

Build the image and run a container:

# Build the image tagged as myapp
docker build -t myapp .

# Run the container, forwarding host port 8000 โ†’ container port 8000
docker run -p 8000:8000 myapp

The -p 8000:8000 flag means: traffic on port 8000 of your machine is forwarded to port 8000 of the container. Without this flag the application runs but is unreachable from outside the container.

Real-World Scenario

You’re developing a Django application. Without Docker:

  1. A new developer clones the repo
  2. Installs Python (possibly the wrong version)
  3. Creates a virtualenv, installs dependencies
  4. Installs PostgreSQL, configures user and database
  5. Sets environment variables
  6. Something goes wrong somewhere between steps 3โ€“4

With Docker:

git clone https://github.com/example/myapp
docker compose up

Done. The same Python version, the same PostgreSQL, the same variables โ€” for everyone on the team.

What Docker Gives a Developer

  • A consistent environment across the whole team
  • Instant startup of databases and services
  • Safe experimentation โ€” break a container, delete it, spin up a new one
  • Simple deploys: build the image, ship it, run it
  • New team member onboarding comes down to a single command

Your reaction to the article

๐Ÿ’ฌ Comments (0)

๐Ÿ” Sign in to leave a comment
๐Ÿšช Login
๐Ÿ’ญ

No comments yet

Be the first to share your opinion about this article!

๐Ÿ”— Similar

Similar articles

Continue learning with these materials

๐Ÿ“

Docker Compose: Multi-Container Applications

Docker Compose is a tool for running multiple related containers as a single application. The...

๐Ÿ“… 08.05.2026 ๐Ÿ‘๏ธ 325
๐Ÿ“

Dockerfile: Building Your Own Images

Dockerfile โ€” a text file with instructions for building an image. Each instruction becomes a...

๐Ÿ“… 08.05.2026 ๐Ÿ‘๏ธ 339
๐Ÿ“

Multi-stage Builds: Shrinking Your Docker Image

A large image means slow downloads, more disk usage, and a bigger attack surface. Multi-stage...

๐Ÿ“… 30.06.2026 ๐Ÿ‘๏ธ 318
๐ŸŽ“ Continue learning

Courses that cover this material

Visit the course to apply this material in practice.

Docker: From Chaos to Containers Open course curriculum