↓Skip to main content
  1. Docker Tutorials/

What Are Docker Repositories and How Do They Work?

·3 mins

A repository is a named collection of related container images stored in a registry. Where a registry is the server, a repository is closer to what most people mean when they say “an image” in casual conversation — nginx, postgres, acme/api — even though each repository actually holds many versions, distinguished by tags.

Repository naming #

A repository name follows the pattern [registry-host/][namespace/]repository:

nginx                                  # Docker Hub, official image
library/nginx                          # same image, fully qualified
bitnami/nginx                          # Docker Hub, user/org namespace
ghcr.io/acme/api                   # GitHub Container Registry
123456789.dkr.ecr.eu-central-1.amazonaws.com/api   # Amazon ECR

If you don’t specify a registry host, Docker assumes docker.io (Docker Hub). If you don’t specify a namespace on Docker Hub, Docker assumes library, which is reserved for Docker’s own “official images” — that’s why docker pull nginx and docker pull library/nginx pull the same thing.

Official images vs. user/org namespaces #

On Docker Hub specifically, repositories fall into two categories:

  • Official images (library/*) — maintained collaboratively with upstream projects and Docker’s own security team, following documented best practices for the base OS and configuration.
  • User and organization images (<namespace>/*) — pushed by anyone with a Docker Hub account. Quality and maintenance vary enormously; treat them the way you’d treat a random npm package.

Other registries structure this differently. ECR and Artifact Registry namespace everything under your cloud account/project; GHCR namespaces under your GitHub user or org.

Creating and pushing to a repository #

Most registries create a repository implicitly the first time you push to it — there’s no separate “create repository” step for the common case:

# note: these two commands would not work without a dockerfile to build from

docker build -t ghcr.io/myuseraccount/myapp:1.4.0 .
docker push ghcr.io/myuseraccount/myapp:1.4.0

If myuseraccount/myapp didn’t exist on ghcr.io yet, this push creates it. Cloud registries (ECR in particular) are sometimes an exception — ECR requires you to create the repository resource first via aws ecr create-repository, because repository-level IAM policies and lifecycle rules attach to that resource.

Public vs. private repositories #

Every registry lets you mark a repository public (anyone can docker pull) or private (requires docker login and appropriate permissions). A few things worth knowing:

  • Free tiers on hosted registries often limit the number of private repositories or pull rate, not public ones.
  • A repository’s visibility is independent of whether individual tags are “stable” or “latest” — there’s no partial visibility per tag.
  • Making a repository public doesn’t retroactively scrub history: if you pushed a secret in an image layer before making it public, that layer is now public too. Rotate the secret; don’t just flip the repository back to private.

Repositories vs. tags, one more time #

It’s worth being precise about this because it trips people up in scripts and CI configs:

  • docker pull ghcr.io/acme/api — pulls the repository’s latest tag (implicit).
  • docker pull ghcr.io/acme/api:1.4.0 — pulls one specific tag within that repository.
  • docker pull ghcr.io/acme/api@sha256:abc123... — pulls one specific, immutable image by digest, bypassing tags entirely.

The repository is the name; the tag or digest is what picks out one specific image within it.