AI Hints
Home›Docker Tutorial›Docker Basics
Docker · Lesson 1 of 8

Why Docker?

The "works on my machine" problem, solved.

⏱ 2 min read▶ Video at 0:00🎓 Free
Watch this lesson in the Docker courseWatch on YouTube ↗Full Docker course

You build an app on your laptop. It works perfectly. You send it to a teammate, or to a server, and it breaks: a different Python version, a missing library, another operating system. This is the oldest problem in software, and Docker exists to solve it.

  • The problem: apps depend on their whole environment
  • The idea: ship the app together with its environment
  • The tool: containers, built and run with Docker

What is a container?

A container is a small, isolated box that holds your app and everything it needs to run: the code, the runtime, the libraries and the settings. The box runs the same way on any computer that has Docker, whether that is your laptop, a colleague's machine, or a cloud server.

Isolatedeach container has its own files, processes and network
Lightweightstarts in about a second, shares the host kernel
Portablethe same image runs on Mac, Windows, Linux and the cloud
Repeatablebuild once, run anywhere, get the same result

Containers vs virtual machines

Virtual machines also isolate apps, but each one carries a full operating system, so they are big and slow to start. Containers share the host's kernel and only package what the app needs.

Virtual machine

  • full guest operating system
  • gigabytes in size
  • boots in minutes
  • heavy on memory

Container

  • shares the host kernel
  • megabytes in size
  • starts in seconds
  • run dozens on a laptop

The Docker vocabulary

WordMeaningAnalogy
Imagea read-only template with your app and its environmenta recipe
Containera running instance of an imagea cake baked from the recipe
Dockerfilea text file with the steps to build an imagethe written recipe card
Registrya place to store and share images (Docker Hub)a recipe library

Check your understanding

Quick check
What is the difference between an image and a container?

Summary

Key takeaways
  • Docker packages an app with its whole environment
  • Containers are small, fast and portable
  • Images are templates, containers are running copies
Next up: Install & Explore Docker Desktop — get Docker running on your computer