o‘zing o‘rgan
Docker and Containers Lesson 1 / 20
Pingvi

What Docker is: the "works on my machine" problem

Containers versus virtual machines, images and containers, installing

Chapter 1. Container basics 15 minutes 4 questions

A familiar situation: a program works on your computer but not on the server. The reason: a different Python version, a different library, a different setting. Docker solves this: it packs the program into a "box" together with everything it needs to run. Wherever the box is opened, it works the same. Docker appeared in 2013 and has become one of the standard ways to run programs on servers.

Containers versus virtual machines

Virtual machine Container
Inside a whole operating system just the program and its libraries
Size gigabytes often tens to hundreds of MB
Start-up minutes seconds
Kernel its own shared with the host

Containers are lightweight: one server easily runs dozens of them.

Two core ideas

Idea Analogy Meaning
Image a recipe / mould an unchanging "snapshot" of the program and environment
Container the cooked dish a live instance started from an image

You can start as many containers from one image as you like. Ready-made images live on Docker Hub: python, nginx, postgres and thousands more.

Installing

  • Windows / macOS: Docker Desktop (on Windows it works with WSL 2).
  • Linux (Ubuntu): the docker-ce package, following the official docs.

Check:

$ docker --version
$ docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.

💡 When several projects on one server (say, a site and a few Telegram bots) run in separate containers, they don't get in each other's way: each has its own Python version and libraries.

Check yourself

Question 1 / 4

Which problem does Docker solve?

Choices

Question 2 / 4

Image versus container?

Choices

Question 3 / 4

Why is a container lighter than a VM?

Choices

Question 4 / 4

Where are ready-made images stored?

Choices