0
0
Dockerdevops~5 mins

Docker Hub as image registry - Commands & Configuration

Choose your learning style9 modes available
Introduction
Docker Hub is a place on the internet where you can store and share your Docker images. It helps you keep your app versions safe and lets others download and use them easily.
When you want to share your app image with your team without sending large files.
When you need a central place to store images for your deployment pipelines.
When you want to use popular pre-built images like databases or web servers.
When you want to keep backups of your app images in the cloud.
When you want to deploy your app on different servers using the same image.
Commands
This command logs you into Docker Hub so you can push and pull images securely.
Terminal
docker login
Expected OutputExpected
Login with your Docker ID to push and pull images from Docker Hub Username: yourusername Password: Login Succeeded
This tags your local image 'my-app' with your Docker Hub username and version '1.0' so Docker knows where to push it.
Terminal
docker tag my-app yourusername/my-app:1.0
Expected OutputExpected
No output (command runs silently)
This uploads your tagged image to Docker Hub so others can download it.
Terminal
docker push yourusername/my-app:1.0
Expected OutputExpected
The push refers to repository [docker.io/yourusername/my-app] 1.0: Pushed Digest: sha256:abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890 Status: Image is up to date for yourusername/my-app:1.0
This downloads the image from Docker Hub to any machine so you can run it there.
Terminal
docker pull yourusername/my-app:1.0
Expected OutputExpected
1.0: Pulling from yourusername/my-app Digest: sha256:abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890 Status: Downloaded newer image for yourusername/my-app:1.0 docker.io/yourusername/my-app:1.0
Key Concept

If you remember nothing else from this pattern, remember: Docker Hub stores your images online so you can share and reuse them anywhere.

Common Mistakes
Trying to push an image without tagging it with your Docker Hub username.
Docker Hub requires images to be tagged with your username to know where to store them.
Always tag your image with your Docker Hub username before pushing, like 'docker tag my-app yourusername/my-app:1.0'.
Not logging in before pushing images.
Without logging in, Docker Hub will reject your push because it can't verify your identity.
Run 'docker login' and enter your credentials before pushing images.
Using 'latest' tag without specifying a version.
Using 'latest' can cause confusion about which image version is running and can lead to unexpected updates.
Use explicit version tags like '1.0' to keep track of image versions.
Summary
Log in to Docker Hub with 'docker login' to authenticate your account.
Tag your local image with your Docker Hub username and version using 'docker tag'.
Push the tagged image to Docker Hub using 'docker push'.
Pull the image from Docker Hub on any machine using 'docker pull'.