Deploying Local Docker Registry

DockerBeginner
Practice Now

Introduction

Docker registry is a platform that enables us to store, manage, and distribute Docker images. While it's convenient to use cloud-based Docker registries like Docker Hub, they come with certain limitations. In this challenge, we will walk through the process of setting up a local Docker registry, allowing us more control over our Docker images and enabling us to work offline.

Setting up a Docker Registry

The step in this challenge will be to set up our local Docker registry. For this, we will utilize the Docker registry image provided by Docker.

Target

The target of this step is to set up a Docker registry.

Result Example

Here are the steps to set up a Docker registry:

  1. Pull the registry image.
Pulling Docker registry image
  1. Create a directory called dockerregistry in the /home/labex path to make it easier for the container image to persist.
Creating dockerregistry directory
  1. Run a container called my-registry with the registry image, map the port, and mount the dockerregistry directory you created as a volume to persist data.
Running Docker registry container
  1. Use curl command to verify that the repository is available.
Verifying Docker registry availability

After completing this step, you will have a running Docker registry instance on your local machine.

✨ Check Solution and Practice

Pushing an Image to the Docker Registry

Now that our Docker registry is up and running, it's time to see it in action! In this step, we'll take a sample Docker image and push it to our local Docker registry.

Target

The target of this step is to push an image to our local Docker registry.

Result Example

Here are the steps to push an image to our local Docker registry:

  1. Pull hello-world image from Docker Hub.
Pulling hello-world image
  1. Create a new tag for the hello-world image using our registry.
Tagging hello-world image
  1. Push the hello-world image to our registry.
Pushing image to local registry

After completing this step, you will have a Docker image pushed to your local Docker registry.

✨ Check Solution and Practice

Pulling an Image from the Docker Registry

The Docker registry is now running and populated with our sample image. In this step, we will demonstrate how to pull an image from our local Docker registry.

Target

The target of this step is to pull an image from the registry.

Result Example

Here are the steps to pull an image from your local Docker registry:

  1. Use the docker rmi command to remove the local copy of the hello-world image that you tagged for the local registry.
Removing hello-world Docker image
  1. Pull an image from the your local Docker registry.
Pulling Docker image locally
  1. Run a container for the image you just pulled.
Running Docker container from image

After completing this step, you will have pulled a Docker image from your local registry.

✨ Check Solution and Practice

Summary

In this challenge, you learned how to set up a local Docker registry, push an image to the registry, and pull an image from the registry. With a local Docker registry, you can have more control over your Docker images and work offline. Congratulations on completing the challenge!