← Lessons

quiz vs the machine

Silver1050

System Design

Containers and Docker

How containers package an app with its dependencies for portable, fast deployment.

4 min read · intro · beat Silver to climb

What a container is

A container bundles your application together with its libraries, runtime, and config into a single isolated unit. Unlike a virtual machine, it shares the host operating system kernel, so it starts in milliseconds and uses far less memory.

Docker is the most common tool for building and running containers.

Images and containers

  • An image is a read only template built from a Dockerfile. It is layered, so unchanged layers are cached and reused.
  • A container is a running instance of an image. Many containers can run from the same image.

Why teams use them

  • Portability the same image runs on a laptop, a CI server, and production.
  • Consistency it works on my machine becomes it works everywhere.
  • Density many containers fit on one host because they are lightweight.

How a build flows

Isolation comes from Linux kernel features such as namespaces and cgroups, which limit what a container can see and how many resources it can use.

Key idea

A container packages an app with its dependencies and shares the host kernel, giving you portable, lightweight, fast starting units of deployment.

Check yourself

Answer to earn rating on the learn ladder.

1. How does a container differ from a virtual machine?

2. What is the relationship between an image and a container?