FresherTechnicalDocker
What is a container registry and what do docker pull and docker push do?
Try answering first
Model answer
A registry is a server that stores and distributes container images. Docker Hub is the default public one. Teams also use private registries such as Amazon ECR, GitHub Container Registry, Google Artifact Registry, Azure Container Registry or Harbor.
An image reference has the form registry/repository:tag, for example registry.example.com/team/app:1.4.2. With no registry in the name, Docker uses Docker Hub, and with no tag, it uses latest.
docker pulldownloads an image from a registry. Image layers are stored separately, so Docker downloads only the layers you do not already have.docker pushuploads a local image to a registry, again sending only layers the registry lacks.
docker login registry.example.com
docker tag app:1.4.2 registry.example.com/team/app:1.4.2
docker push registry.example.com/team/app:1.4.2
docker pull registry.example.com/team/app:1.4.2
You must tag the image with the registry name before you push, and log in first for private registries.
A registry is the shared place where CI publishes an image and servers pull it.
Key points
- A registry stores and distributes images
- Reference format is registry/repository:tag
- Pull and push transfer only missing layers
- Tag with the registry name and log in before pushing
Likely follow-ups
- What is the difference between a tag and a digest?
Common mistakes
- Pushing an image whose name has no registry prefix and landing on Docker Hub
- Forgetting that no tag means latest