No history yet

Docker Fundamentals

What is Docker?

Ever heard a developer say, "It works on my machine"? This phrase is a classic excuse for when code works perfectly for the person who wrote it but breaks as soon as it's moved to a new environment, like a testing server or a colleague's laptop.

Differences in operating systems, software versions, and system libraries can cause major headaches. Docker was created to solve this exact problem. It packages an application and all its dependencies—libraries, settings, and other code—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 books. The container itself has a standard shape and size, so it can be moved and loaded by any ship or crane, anywhere in the world. A Docker container does the same thing for software.

Containerization

noun

The process of packaging software code and all its necessary components, like libraries and frameworks, into a self-contained unit called a container.

This approach is different from using virtual machines (VMs). A VM virtualizes an entire computer, including the hardware and a full guest operating system. Containers, on the other hand, virtualize the operating system itself. They share the host system's kernel, making them much more lightweight and faster to start.

How Docker Works

Docker uses a client-server architecture. You interact with Docker through a command-line tool (the client), which sends instructions to a background service (the daemon) that does the heavy lifting of building, running, and managing your containers.

There are three core components in this architecture:

  • Docker Daemon: The background service running on the host machine that manages everything. It listens for API requests from the Docker Client.
  • Docker Client: The command-line tool you use to talk to the Docker Daemon. When you type a command like docker run, the client sends it to the daemon.
  • Docker Registry: A remote location for storing and distributing Docker images. The default public registry is Docker Hub, but you can also run a private one.

Two other terms you'll hear constantly are images and containers.

An image is a read-only template with instructions for creating a container. It's like a blueprint or a recipe. It contains the application code, a runtime, libraries, and other files the application needs to run.

A container is a runnable instance of an image. You can create, start, stop, move, or delete a container using the Docker API or client. It's the living, running application that was built from the blueprint.

ConceptAnalogyState
ImageA recipeRead-only
ContainerA cake from the recipeWritable

Why Use Docker?

The main benefit of Docker is consistency. By packaging the application and its dependencies together, Docker ensures that it runs the same way everywhere. This eliminates the "it works on my machine" problem entirely.

It also brings other advantages:

Portability: Containers can run on any system that has Docker installed, whether it's a developer's laptop, a server in a data center, or a cloud provider. This makes moving applications between environments simple.

Efficiency: Because containers share the host machine's operating system kernel, they are much smaller and start almost instantly compared to virtual machines. This means you can run many more containers on a single server, making better use of your hardware.

With Docker, the goal is simple: package your application once, and then run it anywhere.

Ready to review these foundational ideas? Let's check your understanding.

Quiz Questions 1/5

What is the primary problem Docker was designed to solve?

Quiz Questions 2/5

In the Docker world, what is the difference between an image and a container?

Understanding these core concepts—containerization, the client-daemon architecture, images, and containers—provides a solid foundation for working with Docker.