Skip to content
Laviyx Learn

Try

Docker and Kubernetes course menu

What Is Docker? Containers Explained for Beginners

What Docker and containers are, the problem they solve, how containers differ from virtual machines, the key words: image, container, Dockerfile and registry, and how this course works.

Beginner4 min readUpdated
On this page

Docker packages an application together with everything it needs to run: its code, libraries and settings. That package runs in the same way on your laptop, a teammate's laptop and a production server.

Docker is now a standard tool for developers, and essential for DevOps, cloud and machine learning engineers.

The problem Docker solves#

Every developer has heard this: "It works on my machine." An app may need Python 3.13, a certain library version and a system package. A server might have something different, and the app fails.

Docker's answer is to ship the whole environment with the app. If it runs in a container on your laptop, it should run the same way anywhere.

Key words#

WordMeaning
ImageA read-only package with the app and everything it needs
ContainerA running instance of an image
DockerfileA text file with instructions for building an image
RegistryA place to store and share images, such as Docker Hub
VolumeStorage that survives when a container is removed

Think of an image as a recipe or a class, and a container as a dish made from it, or an object. One image can run as many containers.

Text
Dockerfile  --docker build-->  Image  --docker run-->  Container
                                 |
                            docker push
                                 v
                              Registry

Containers and virtual machines#

A virtual machine runs a whole operating system. A container is an isolated process that shares the host's Linux kernel, so it is much lighter.

Virtual machineContainer
ContainsA full operating systemThe app and its libraries
Typical sizeGigabytesMegabytes
Starts inMinutesSeconds or less
IsolationVery strongStrong, but shares the kernel
Text
Virtual machines            Containers
+-------+ +-------+         +-----+ +-----+ +-----+
| App   | | App   |         | App | | App | | App |
| OS    | | OS    |         +-----+ +-----+ +-----+
+-------+ +-------+         |   Docker engine     |
|   Hypervisor    |         |   Host OS (kernel)  |
|   Host OS       |         +---------------------+
+-----------------+

On Windows and macOS, Docker runs a small Linux virtual machine in the background, because containers need a Linux kernel.

Why teams use it#

  • Consistency: the same image runs in development, testing and production.
  • Fast setup: new developers can start a whole stack with one command.
  • Isolation: apps with different dependencies run side by side.
  • Easy rollback: go back to the previous image.
  • Scaling: run more copies of the same image.

How this course works#

You will start with single containers, then build your own images, connect containers, and run whole applications with Docker Compose. The final section introduces Kubernetes.

Every command that shows output in this course was run with Docker on Ubuntu while writing it, and the Kubernetes commands ran on a real local cluster. The output is real, apart from some download and build progress lines, which are shortened. Your container IDs, sizes and times will be different.

If you are new to the command line, start with our Linux course, especially Your First Commands.

Key takeaway#

Next: Installing Docker.

Finished this lesson?

Some links are affiliate links. If you buy through them, Laviyx Learn may earn a commission at no extra cost to you. As an Amazon Associate, we earn from qualifying purchases.