No history yet

Introduction to Docker

The “Works on My Machine” Problem

Every developer knows the frustration. You build an application, it runs perfectly on your laptop, but when you send it to a colleague or deploy it to a server, it breaks. This is often because the new environment is different—it might have a different operating system version, other installed software, or missing libraries.

Docker solves this problem by packaging an application and all its dependencies into a single, standardized unit called a container. Think of it like a real-world shipping container. It doesn't matter what's inside—electronics, bananas, or clothes—the container itself can be handled, shipped, and unloaded by any standard crane or ship. Similarly, a Docker container can run on any computer that has Docker installed, regardless of the underlying system.

By packaging applications and their dependencies into standardized units called containers, Docker ensures that software runs seamlessly across different environments.

This process of creating and managing containers is known as containerization. It ensures your application works consistently everywhere, from development to testing to production.

Containers vs. Virtual Machines

Before containers, the main solution for isolating applications was the virtual machine (VM). A VM is an entire computer emulated in software. It includes a full copy of an operating system, the application, and any necessary libraries and binaries. This works, but it's heavy. A VM can take up many gigabytes of space and be slow to start.

Containers take a more efficient approach. Instead of virtualizing the hardware, they virtualize the operating system. This means multiple containers can share the host machine's OS kernel. They only package the application and its specific dependencies. This makes them incredibly lightweight, fast, and resource-efficient.

FeatureVirtual Machine (VM)Container
IsolationFull hardware virtualizationOS-level virtualization
OverheadHigh (Full OS per VM)Low (Shares host kernel)
SizeGigabytesMegabytes
Start-up TimeMinutesSeconds
Resource UsageHigh (RAM, CPU, Disk)Low
PortabilityLess portableHighly portable

Docker's Architecture

Docker uses a client-server architecture. You interact with Docker through a client, which then communicates with a long-running server process called the Docker daemon.

There are three main components:

Docker Client

noun

The command-line interface (CLI) tool that lets you interact with Docker. When you type a command like docker run, the client sends this command to the Docker daemon.

Docker Daemon

noun

The Docker server, also known as dockerd. It's a background process that listens for API requests from the Docker client and manages all the Docker objects, such as images, containers, networks, and storage volumes.

Docker Registry

noun

A storage system for Docker images. You can think of it as a GitHub for Docker images. Docker Hub is the default public registry, but you can also run your own private registry.

When you issue a command like docker pull ubuntu, the client tells the daemon to pull the ubuntu image from the Docker Hub registry. If you then run docker run ubuntu, the client tells the daemon to create and run a new container from that image.

This setup allows you to manage Docker on your local machine or connect a client to a daemon running on a remote server, giving you flexibility in how you manage your containers.

Quiz Questions 1/5

What is the primary problem Docker was created to solve?

Quiz Questions 2/5

What is the key difference between a Docker container and a virtual machine (VM)?