레슨 1 · 20 min

What is a container?

The "works on my machine" problem, what a container is, how it differs from a virtual machine, what images are and what Docker is used for.

The problem: “it works on my machine”

You finish a web application. On your computer it works perfectly. You hand it to a teammate and it won’t start: she has a different version of Node, a system library is missing and her database is configured differently. Then you deploy it to the server and it fails again, for a different reason.

The code is the same on all three computers. What changes is everything else: the operating system, the installed versions, the configuration variables, the files the app expects to find.

Docker solves exactly that: it packages your application together with everything it needs to run, so it works the same everywhere.

What is a container?

A container is an isolated process running on your computer with its own filesystem, its own network and its own environment variables. From the inside it looks like a complete Linux computer; from the outside it’s just one more program.

The analogy comes from shipping containers. Before they existed, every ship loaded sacks, barrels and crates of different sizes, and loading or unloading was slow and fragile. The standard container changed everything: no matter what’s inside, every crane, ship and truck knows how to move it.

Software works the same way: it doesn’t matter whether your app is Node, Python or Java. If it’s in a container, any machine with Docker knows how to run it.

Container vs. virtual machine

A virtual machine (VM) simulates a complete computer, with its own entire operating system. A container shares the system kernel with the machine it runs on and only brings the files its app needs.

Virtual machineContainer
What it includesA complete operating systemOnly the app and its dependencies
Typical sizeSeveral GBFrom a few MB
Startup timeMinutesSeconds or less
How many fit on a laptopA fewDozens or hundreds
IsolationVery strongStrong, but they share the kernel

They're not enemies

In the cloud it’s very common to run containers inside virtual machines: the VM isolates customers from each other and the containers organize each customer’s applications.

Image and container

These two terms appear throughout the course and they’re easy to mix up:

  • An image is the template: a read-only package with the filesystem and configuration of the app (for example, “nginx version 1.27”).
  • A container is a running instance of that image.

The relationship is like a recipe and cakes: from one recipe you can bake many cakes, and each one can be decorated differently without changing the recipe. From one image you can create many containers.

One image, several containers
image nginx:1.27
   ├── container "web-1"
   ├── container "web-2"
   └── container "testing"

What is Docker?

Docker is the tool that builds images, shares them and runs containers. It has several pieces:

PieceWhat it’s for
Docker EngineThe service running in the background that manages containers
Docker CLIThe docker command you type in the terminal
Docker DesktopThe app for Windows and macOS that installs all of the above
Docker HubAn online registry with thousands of ready-to-use images
Docker ComposeA tool to run several apps together from one file

Docker is used by everyone from students to companies like Spotify, PayPal or Mercado Libre. If you work in web development, backend, data or DevOps, you’ll find it in almost every project.

What it’s used for

  • Identical development environments for everyone: the team starts the app and its database with a single command.
  • Trying things without installing: want PostgreSQL 16 or Redis? You run a container and delete it when you’re done, without cluttering your computer.
  • Deployment: the same image you tested on your laptop is the one running in production.
  • Microservices: each part of the system lives in its own container and is updated separately.
  • CI/CD: automated tests run inside clean containers every time.

Your practice terminal

In every lesson you’ll find a terminal like this one. It has a simulated Docker that runs inside your browser: you can download images, create containers and build your own images without installing anything. The Reset button makes it brand new again.

It's a simulation

The terminal imitates the behavior and messages of real Docker, but it doesn’t download anything from the internet: the images are practice versions. When you install Docker (in the next lesson), every command in the course works the same way on your computer.

Try it: type docker --version and press Enter. Then try docker --help to see the list of commands.

Try it
이 연습용 터미널에는 JavaScript가 필요합니다.
해 보기:

Test what you learned

What's the difference between an image and a container?

Why does a container start much faster than a virtual machine?

What problem does Docker mainly solve?

Challenge

Before moving on, think about a project of your own (a page, an API, an assignment with a database) and answer:

  1. What would another person have to install to run it on their computer?
  2. Which parts could go in separate containers?

Then, in the terminal, run docker --help and find which command lists containers and which one lists images.

연습용 터미널
이 연습용 터미널에는 JavaScript가 필요합니다.
해 보기:
See a sample answer

An online shop built with Node and PostgreSQL would need: the right Node version, the npm dependencies, a PostgreSQL database with its user and password, and the configuration variables. In containers, the Node app would go in one and PostgreSQL in another.

In docker --help, ps lists containers (“List containers”) and images lists images (“List images”). You’ll use them in lessons 4 and 8.

레슨을 완료하세요 퀴즈를 모두 맞히면 완료로 표시됩니다.
강좌를 완료했어요! 배지를 획득했어요: Docker Basics 내 배지 보기

강좌를 완료했어요!

배지를 획득했어요: Docker Basics

내 배지 보기
1 / 1

디지털 존재감을 만들어 보세요

오늘 시작하세요. 메시지를 보내 주시면 24시간 이내에 답변드려요.