shouldenough

DevOpsLearn Docker by Dockerizing Your App

Lesson 5 of 10

Lesson 05/7 minutes/2 graded

Public and private registries

Where images live, why Docker Hub is the default, what an official image means, and the difference between a registry and a repository.

Images have to live somewhere before you can run them. That somewhere is a registry: storage built for Docker images, the same way npm hosts packages.

Docker Hub is the default

Docker runs the biggest registry, called Docker Hub, and Docker looks there without being told. When I type docker pull nginx, nothing in that command mentions Docker Hub. It is simply where Docker goes when you do not name another place.

You do not need an account to download public images. Open hub.docker.com, search for a service, and you get the image plus a page explaining how to use it.

Official images, and why the label matters

Search for redis or postgres and some results carry a "Docker official image" label. Those are maintained by a team at Docker working with the people who make the technology, with security review as part of the deal. Anyone can publish to Docker Hub, so when two images look equally good, the labelled one is the safer pick.

Private registries, for your own images

Your company's app image is not something you want sitting in public. That is what private registries are for, and every cloud provider sells one. AWS calls theirs ECR, and Google, Azure and Nexus all have their own. Docker Hub itself gives you private repositories too, so you can start there before deciding.

They all behave the same way as Docker Hub, with one extra step: you log in first, with docker login, and then pull and push as usual.

Registry and repository are not the same word

These two get used loosely and it confuses everyone at first.

A registry is the service that stores images. Docker Hub is a registry. AWS ECR is a registry.

A repository is one folder inside that registry, holding all the versions of a single app. So your payments-api repository holds every version of the payments API, and your web-frontend repository holds every version of the frontend. One app, one repository, many versions inside it.

Pull one down

Pick a version rather than taking whatever is newest. I used nginx:1.30.4-alpine, and the part after the colon is the tag, which we cover properly later.

~

Download the nginx image, version 1.30.4-alpine, from Docker Hub.

Docker prints a line per layer as it downloads. Run docker images afterwards and it is in your list, 63.7 MB on my machine.

Check yourself

Knowledge check2 questions
Question 1 of 2
Where does Docker look for an image when you do not name a registry?