How to set up a Private, Remote and Virtual Docker Registry

How to setup Docker Registry

The simplest way to manage and organize your Docker images is with a Docker registry. You need reliable, secure, consistent and efficient access to your Docker images that’s shared across your team in a central location. Including a place to set up multiple registries, that work transparently with the Docker client.

With the JFrog Container Registry, powered by Artifactory, you can set up a free local, remote and virtual Docker Registry in minutes. This blog post will take you through the steps.

Before you start

Here’s what you’ll need:

Step 1: Login to your environment

Login using the default username: admin, and password: password for the on-prem installation, or the credentials provided to you by email for the cloud installation.

Login to your environment

Step 2: Add local Docker repository

Used to store your custom Docker images you will create in a later step. 

Navigate to the Administration Module. Expand the Repositories menu and click on the Repositories menu item. 

Add a new Local Repository with the Docker package type. Enter the Repository Key “docker-dev-local” and keep the rest of the default settings.

Add local Docker repository

Step 3: Add remote Docker repository

Used as a caching proxy, to store 3rd party images from Docker Hub or any other external registries. 

Click on the Remote tab on the Repositories page and add a new Remote Repository with the Docker package type. Enter the Repository Key “docker-hub-remote” and keep the rest of the default settings.

Add remote Docker repository

Step 4: Add virtual Docker repository

Used when creating your custom Docker image.

Click on the Virtual tab on the Repositories page and add a new Virtual Repository with the Docker package type. Enter the Repository Key “docker” and add the local and remote docker repositories you created in Steps 2 and 3 (move them from Available Repositories to Selected Repositories using the arrow buttons). The order of these repositories in the list will determine the order used to resolve the dependencies required for building your docker image. Select your local repository that you created in Step 2 as the Default Deployment Repository. The Default Deployment Repository is the repository that the docker image you build will be pushed to. Keep the rest of the default settings.

Add virtual Docker repository

Step 5: Fork the JFrog Docker example GitHub repo 

This repository contains a simple Dockerfile you will use to build your custom image.

Fork the JFrog Docker example GitHub repo

Step 6: Update the base image reference

Clone your forked repository and update the FROM line of the Dockerfile to reference your virtual Docker repository.

FROM ${SERVER_NAME}-${VIRTUAL_REPO_NAME}.jfrog.io/alpine:3.11.5

The SERVER_NAME is the first part of the URL given to you for your environment: https://SERVER_NAME.jfrog.io

The VIRTUAL_REPO_NAME is the name “docker” that you assigned to your virtual repository in Step 4.

Update the base image reference

Update the base image reference_2

Step 7: Push custom image to your Docker repository

Log in to your virtual repository, build, tag and push your custom image with the following commands:

$ docker login ${SERVER_NAME}-${VIRTUAL_REPO_NAME}.jfrog.io
$ docker build --tag ${SERVER_NAME}-${VIRTUAL_REPO_NAME}.jfrog.io/my-docker-image:latest .
$ docker push ${SERVER_NAME}-${VIRTUAL_REPO_NAME}.jfrog.io/my-docker-image:latest

Push custom image to your Docker repository

Step 8: View the images in your Docker Registry

Navigate to the Application Module, expand the Artifactory menu and click the Artifacts menu item. In the Artifact Tree View, expand the docker, the docker-dev-local and the docker-hub-remote repositories to see your new artifacts. Click on your image in your docker-dev-local repository to see its details.

View the images in your Docker Registry

Your Docker Registries

Once you’re done and configured your Docker registries, you’ll be able to store all your Docker images in your local, remote and virtual repositories. Here’s how it will look:

Docker info

Docker info

Docker manifest properties

Docker manifest properties

Manifest JSON file

Manifest JSON file

That’s it!

Now, all that’s left is for you to try it for yourself.