LOGBOOK

HELP

← again tap: answer good → ↑ swipe up at the end: next

1 / 9 Part 1 of 5
Other keys: show • Space: good • 1-4: rate • 0: skip • 5: flag

Question

What is a Docker image, and how does it relate to a container?

Answer

image OS files + libraries + app + metadata alpine: minimal OS filesystem libraries application files each layer: only the difference to the one below read-only: the layers never change container 1 writable layer one thin writable layer per container container 2 writable layer same layers on disk, shared the image stays unchanged image = class, container = instance

Explanation in 7 steps

An image is a read-only, layered template (filesystem plus metadata); a container is a running instance of it with its own thin writable layer on top.

An image bundles everything an application needs to run: a minimal OS filesystem (for example Alpine), libraries, the application files, and metadata such as environment variables, the exposed port and the default command. It is built from a Dockerfile and stored as a stack of layers, one per filesystem-changing instruction, each layer recording only the difference to the one below.

Images are immutable. When you start a container, Docker stacks the image's read-only layers and adds one thin writable layer for that container. Everything the running process changes goes into that writable layer, so:

  • many containers can start from the same image and share its layers on disk, which is why ten containers do not cost ten times the space;
  • deleting the container throws away its writable layer, while the image stays unchanged.

The class/object analogy fits: the image is the class, each container an instance.

Because several container engines exist besides Docker (Podman, containerd, CRI-O), the Open Container Initiative (OCI) standardises the image format (how layers and their metadata look), so an image built with one tool runs on another.

Two containers share the read-only image layers; each writes only to its own writable layer

* Shared read-only layers below, one private writable layer per container on top. *

Go deeper:

or press any other key

Question

Where do Docker images come from, and how does a short name like alpine:latest resolve to a registry?

Answer

Docker host registry repositories, with tags for versions Docker Hub also: ghcr.io, Quay, private registries registry / namespace / repository : tag whatever is left out gets a default alpine latest docker.io alpine:latest library library = the curated official images docker.io/library/alpine:latest FROM alpine:latest  →  pulled from Docker Hub latest is a tag name, not a guarantee pin a tag or a digest for reproducible builds

Explanation in 7 steps

From a registry, by default Docker Hub: alpine:latest is short for docker.io/library/alpine:latest.

A registry is a server that stores and distributes images, organised into repositories with tags (versions). Docker Hub (hub.docker.com) is the default public registry; others include GitHub Container Registry (ghcr.io), Quay and private, self-hosted registries.

An image reference has the form [registry/][namespace/]repository[:tag]. Whatever is left out gets a default:

Part Default In alpine:latest
Registry docker.io (Docker Hub) docker.io
Namespace library (the curated "official images") library
Tag latest latest (given)

So when docker image build meets FROM alpine:latest and the image is not cached locally, the build output shows it being pulled from docker.io/library/alpine:latest. A name like myregistry.example.com:5000/team/app:1.2 points somewhere else entirely.

latest is just a tag name, not a guarantee of anything. It is whatever the publisher last tagged that way, so pin a concrete tag (or a digest) when reproducibility matters.

Go deeper:

or press any other key