Docker logoDocker
System DesignFree preview

Storing and Distributing Multi-GB Container Images

Design a container image distribution service. Users push images that are hundreds of MB to several GB, pull them by tag or digest, list available images, and search.

SWE
Infra Eng
system-design
docker
storage
cdn
caching
api-design
distributed-systems
networking
Frequency
Single report
Last asked
—
Stage
onsite-system-design

Problem

Design a container image distribution service. Users push images (hundreds of MB to several GB each), pull them by tag or by digest, list the images and tags that exist, and search for images.

Cover the API surface, the data model, the push and pull flows, how concurrent pushes to the same tag behave, how unused data is reclaimed, and a capacity estimate. A reasonable planning load is about 5M pulls per day.

Hints

Pitfalls

  • A layer still referenced by another image cannot be deleted; only manifests are deleted, and a layer goes only when no manifest references it (reference counting or reachability sweep).
  • Moving a tag does not delete the old manifest; it stays pullable by digest until GC.
  • Without dedup, 100M images at about 1 GB is roughly 100 PB; a typical 10x layer dedup brings it near 10 PB.

Talking Points

  • Content-addressed layers are the foundation: dedup, CDN caching, HEAD checks and incremental pulls all follow from it.
  • Keep tag resolution and blob retrieval separate so they scale and cache independently.
  • State the concurrent-push answer explicitly: atomic tag update, last writer wins, data committed before the flip.
  • Walk through the HEAD-before-upload optimization; it shows you know how clients behave.
  • Do the capacity math aloud (58 TPS average, about 250 peak).
  • Treat GC as a correctness issue: use a grace period so sweeps do not race in-flight pulls.
  • Tag-addressed manifests need short TTLs; layers cache forever.
  • Mention rate limits and cost; it is the real business pressure on a public registry.

Follow-ups

Multi-architecture images? Tag resolves to a manifest list pointing at per-platform manifests; client picks by OS/arch.
A push fails halfway? Uploads go to a temp location and become visible only when finalized with the digest; a background job cleans abandoned uploads.
A layer is corrupted in storage? Re-hash on read to detect it; repair needs replication or erasure coding in the object store.
Per-user rate limits or quotas? Track bytes pushed and pulled per account per window, enforce at the gateway, throttle or reject past quota.
Private registry for 10 users versus public for millions? Same architecture; metadata DB scale and CDN need differ, and the small one can run on one box.

Preparation

  • Run a local registry:2, inspect its on-disk layout.
  • Sketch the push and pull sequence from memory in 10 minutes, including HEAD check and tag flip.
  • Write the five-table schema and say which index serves each query.
  • Redo the capacity estimate (TPS, daily storage, dedup effect) in under 5 minutes.
Was this article helpful?

Comments

Sign in to join the discussion
Loading...