If you have ever heard a developer say "it works on my machine", you already understand the problem Docker was built to solve. Docker is a platform for packaging an application together with everything it needs to run - code, runtime, libraries, and system settings - into a single portable unit called a container. In this first lesson of our Docker series you will learn what containers are, why they beat older approaches, and how the core pieces of Docker fit together.
A typical web application depends on far more than its own source code. It needs a specific language runtime, a set of libraries, environment variables, and often system packages. When each developer, test server, and production server installs these pieces by hand, the environments slowly drift apart. An app that runs perfectly on a laptop with Node 20 may crash on a server running Node 16. Debugging these mismatches wastes enormous amounts of time.
Containers fix this by shipping the environment with the app. The same container image runs identically on your laptop, a teammate machine, a CI server, and a cloud host.
Before containers, the standard isolation tool was the virtual machine. A VM emulates an entire computer, including its own operating system kernel, which makes it heavy: gigabytes of disk, minutes to boot, and significant memory overhead.
A container takes a lighter approach. All containers on a host share the host operating system kernel and are isolated using Linux features such as namespaces and cgroups. The result:
VMs still matter when you need full kernel isolation, but for packaging and running applications, containers are the modern default.
Docker is built around a few ideas you will use constantly:
docker command line client.Once Docker is installed (covered in the next lesson), running your first container takes one command:
docker run hello-worldBehind the scenes Docker checks whether the hello-world image exists locally, downloads it from Docker Hub if not, creates a container from it, and runs it. A more useful example starts a real web server:
docker run -d -p 8080:80 nginxThis launches the Nginx web server in the background and maps port 8080 on your machine to port 80 in the container. Visit http://localhost:8080 and you are serving pages from a container - without installing Nginx on your system at all.
docker run, can download and start a complete application.Next up: Installing Docker and First Commands, where you will set up Docker on your own machine and learn the essential commands every Docker user relies on.