Images and registries
Tags name image versions, and registries such as Docker Hub store and share images.
- Pull an image with docker pull and upload with docker push.
- Read a tag as registry/image:tag.
- Pin specific versions instead of relying on latest.
- Prefer small base images to reduce image size.
In plain English
A registry is a remote library that stores and shares images, and Docker Hub is the public registry Docker checks by default. An image tag is a label that names a version, so nginx:1.27 and nginx:alpine point at different builds of the same image. docker pull downloads an image from a registry, and docker push uploads one you built, after you log in with docker login. Tags such as latest are mutable, meaning the same tag can silently point at a new image later, so pin a specific version or a digest for repeatable builds. An image is made of stacked layers, so choosing a small base image and installing fewer packages keeps pull times and disk usage low.
Step by step
- 1Log in to Docker Hub with docker login.
- 2Pull an image by tag with docker pull node:22-alpine.
- 3Tag a local image for your Docker Hub account with docker tag.
- 4Upload the image with docker push.
- 5Compare image sizes with docker images.
docker login
docker pull node:22-alpine
docker tag node:22-alpine myname/my-app:1.0
docker push myname/my-app:1.0
docker imagesCommon mistakes
- Deploying latest means a later pull can bring different code than the one you tested.
- Pushing to Docker Hub without logging in first fails with a permission error.
- Assuming a larger image is better is wrong; extra packages slow pulls and widen the attack surface.
- Forgetting to tag an image before push fails, because Docker needs a registry and repository name.
Tag and push an image
Tag the node:22-alpine image as yourname/my-app:1.0 and push it to Docker Hub.
docker loginWhy should you avoid the latest tag in production?
Make it yours.
Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.
Lock in what you just learned.
Mark this lesson complete to save your place and move one step closer to the certificate.