Docker Tutorial · Docker Basics · Lesson 1 of 26

What Is Docker?

What containers are, why Docker made them popular, and how containers differ from virtual machines.

Create a free account to save this page, take notes and track your progress. Sign in

The short answer

Docker is a set of tools for building, sharing and running containers. A container packages an application with everything it needs (runtime, libraries, files, configuration) and runs it as an isolated process on a Linux kernel. The same container runs the same way on a laptop, in CI and in production.

  • An image is a read-only template: layers of files plus metadata (which command to run, environment, ports).
  • A container is a running (or stopped) instance of an image, with its own writable layer.
  • A registry (Docker Hub, GitHub Container Registry, your cloud's registry) stores and distributes images.

Containers versus virtual machines

Virtual machine Container
Isolation Own kernel on a hypervisor Shared host kernel (namespaces and cgroups)
Start time Tens of seconds Milliseconds to seconds
Size Gigabytes Megabytes
Best for Different operating systems, strong isolation Packaging and running applications
Run your first container
docker version --format 'Docker Engine {{.Server.Version}} on {{.Server.Os}}/{{.Server.Arch}}'
docker run --rm alpine:3.24 sh -c 'echo "Hello from a container running $(cat /etc/alpine-release)"'

Output

Docker Engine 29.7.2 on linux/amd64
Hello from a container running 3.24.3

Run this on your computer — see “Get Started” for setup.

Every example in this tutorial is a real shell script run against Docker Engine when the page was built; the output shown is what Docker printed. See the Docker overview.

Test yourself

What is the difference between an image and a container?

  1. They are the same thing
  2. An image is a read-only template; a container is a running instance of it
  3. A container is stored in a registry; an image runs
  4. Images only work on Linux laptops
Show answer

Answer: An image is a read-only template; a container is a running instance of it

You build and share images; you run containers from them.

Was this page helpful?