Docker Tutorial
Estimated reading: 5 minutes 37 views

🏢 Docker Registry – Manage and Share Container Images Easily

🧲 Introduction – Why Docker Registries Matter

In modern DevOps and containerized workflows, Docker registries are the central hubs for storing, sharing, and managing Docker images. Whether you’re deploying apps across teams or building automation pipelines, using a Docker registry ensures consistency, versioning, and access control for your container images.

In this guide, you’ll learn:

  • 📦 What Docker Registry is and how it works
  • 🔐 How to log in and push/pull images using Docker CLI
  • 🏗️ How to set up a private registry
  • 📤 How to publish your images to Docker Hub or your own registry

📋 Topics Covered

📌 Topic📖 Description
What is Docker RegistryCentralized service for storing and retrieving Docker images.
Docker Hub OverviewThe default public registry used by Docker users worldwide.
Docker Hub Login/Sign UpHow to create an account to use Docker Hub.
Private Docker Registry SetupRun your own internal Docker registry securely.
Registry Server ConfigurationConfiguration options for custom registries.
Login to Docker Registries via CLIAuthenticate with docker login.
Logout from Docker Registries via CLIEnd sessions using docker logout.
Pull Images from Docker RegistriesUse docker pull to download images.
Push Images to Docker RegistriesUse docker push to publish images.

📦 What is Docker Registry?

A Docker Registry is a storage and distribution system for Docker images.

There are two main types:

  • Public Registries: Like Docker Hub, accessible to anyone.
  • Private Registries: Custom, secure registries hosted internally.

Registries support operations like:

  • Storing images
  • Versioning via tags
  • Pushing new builds
  • Pulling images for deployment

Docker uses Docker Hub as the default registry unless another is specified.


🌍 Docker Hub Overview

Docker Hub (https://hub.docker.com) is the most popular cloud-based Docker registry.

Features:

  • Free hosting for public repositories
  • Paid plans for private repos
  • Automated builds from GitHub/GitLab
  • Stars, descriptions, and documentation

Popular images: nginx, ubuntu, mysql, node, python.


🔐 Docker Hub Login/Sign Up

To use Docker Hub:

📝 Step 1: Sign Up

Visit: https://hub.docker.com/signup

🔐 Step 2: Login via CLI

docker login

You’ll be prompted to enter your username and password.

💡 Once logged in, Docker CLI remembers your session until you log out.


🏠 Private Docker Registry Setup

You can run your own Docker registry using the official image:

🔧 Step-by-Step:

docker run -d -p 5000:5000 --name registry registry:2
  • This starts a local registry on http://localhost:5000
  • You can now push/pull images from this server

⚙️ Registry Server Configuration

To customize your registry server:

  1. Create a config file:
mkdir -p /opt/registry
vi /opt/registry/config.yml
  1. Example configuration:
version: 0.1
log:
  level: info
storage:
  filesystem:
    rootdirectory: /var/lib/registry
http:
  addr: :5000
  1. Run with custom config:
docker run -d -p 5000:5000 \
  -v /opt/registry:/etc/docker/registry \
  -v /registry-data:/var/lib/registry \
  registry:2

🔑 How to Log into Docker Registries Using Docker CLI

Use the following to authenticate:

docker login <registry_url>

Example:

docker login myregistry.example.com

You’ll be prompted for username and password or access token.


🚪 How to Logout from Docker Registries Using Docker CLI

To clear your Docker session from a registry:

docker logout <registry_url>

Example:

docker logout myregistry.example.com

For Docker Hub:

docker logout

📥 How to Pull Docker Image from Registries

To download an image:

docker pull <image_name>:<tag>

Examples:

docker pull nginx:latest
docker pull myregistry.example.com/myapp:v1

💡 Docker will try Docker Hub if no registry is specified.


📤 How to Push Docker Image to Registries

Before pushing, make sure the image is tagged properly:

docker tag myapp myusername/myapp:v1

Push to Docker Hub:

docker push myusername/myapp:v1

Push to Private Registry:

docker tag myapp myregistry.example.com/myapp:v1
docker push myregistry.example.com/myapp:v1

Make sure you’re logged in before pushing.


📌 Summary – Recap & Key Takeaways

Docker registries are central to any containerized DevOps workflow. Whether using Docker Hub or a private setup, they help distribute, store, and version your images effectively.

🔍 Key Takeaways:

  • Docker Hub is the default registry, but private registries offer control.
  • Use docker login and docker push/pull to interact with registries.
  • Tag images correctly before pushing them to avoid naming errors.
  • Run registry:2 to set up a local registry for internal use.

⚙️ Mastering Docker registries helps you build robust CI/CD pipelines and collaborative container environments.


❓ Frequently Asked Questions (FAQs)

❓ What is the default Docker registry?
✅ Docker Hub (hub.docker.com) is used by default when no registry is specified.


❓ Can I host my own Docker registry?
✅ Yes, you can run registry:2 as a local/private registry on any server.


❓ How do I push images to a private registry?
✅ Tag the image with the registry address and then use docker push.


❓ Do I need to log in every time I push or pull?
✅ No. Once you run docker login, the session is saved. But logout is manual.


❓ Are Docker registries secure?
✅ Docker Hub supports 2FA and access tokens. Private registries can be secured with TLS and basic auth.


❓ How do I delete an image from Docker Hub or private registry?
✅ Use the Docker Hub web interface or API. For private registries, you may need garbage collection enabled.


❓ Can I mirror Docker Hub locally?
✅ Yes, using tools like Harbor or by configuring a caching proxy registry.


Share Now :

Leave a Reply

Your email address will not be published. Required fields are marked *

Share

Docker Registry

Or Copy Link

CONTENTS
Scroll to Top