Replicate

Replicate public container images

If you plan to run a registry in your platform, it could be a good idea to replicate container images from public registries (e.g. Docker Hub or quay.io) to your registry avoiding possible downtimes caused by these third parties.

quay.io and Docker Hub are public container registries which could be affected by outages out of your control, as all third-party dependencies. This guide helps to increase your business resilience to outages from public services.

Requirements

  • Connectivity to the registry (including credentials)

Hands-on

Make sure you know the Harbor external hostname, username, and password.

Let's assume these values in this example:

  • Hostname: harbor.example.com
  • Username: admin
  • Password: Harbor12345

Log in the Harbor web console:

Library

To start replicating container images from public repositories you have to declare what is your upstream container registry.

Navigate to Administration -> Registries

Registries

Then, click the + NEW ENDPOINT button to declare the upstream container image registry. As an example, lets replicate images from quay.io

Quay

Configure the registry details as shown in the previous image and click OK.

Feel free to test connectivity before clicking OK. Harbor should be able to reach the upstream registry.

Registry list

Navigate to Administration -> Replications

Quay

Then, click the + NEW REPLICATION RULE button to create a new replication rule. As an example, lets replicate node_exporter images version 0.18 from quay.io.

Replication Rule

This replication rule specifies:

  • Name: Simple name of the rule. Example: node-exporter-0-18-from-quay
  • Description: Description of the rule. It can be empty. Example: Replicate prometheus node-exporter 0.18 from quay
  • Replication mode: Pull or Push. Pull downloads images from the source registry, Push from Harbor to an upstream registry. Example: Pull
  • Source Registry: Upstream registry. Must be declared before. Example: quay.io
  • Source resource filter: Filter the name and tags. Example: prometheus/node_exporter:v0.18*
  • Destination namespace: Destination project + registry where to place the container images. Example: library
  • Trigger mode: Describes how to trigger this rule. Manual or Scheduled. Example Manual.

In some use cases is a good idea to run this rule using a schedule.

Click SAVE

Replication Rule List

Now you can see the rule. Select it and press REPLICATE button to start replicating from quay.io.

Replication Rule Execution

Wait until the execution success rate raises 100%. It could take up to two minutes to run this example.

Now Navigate back to Projects -> library -> Repositories:

node-exporter

It should be present a new repository inside the library project named node_exporter. It will contain images copied from quay.io.

node-exporter-images

Then you will be able to pull the node_exporter container image from your Harbor instance:

$ docker pull harbor.example.com/library/node-exporter:v0.18.1
v0.18.1: Pulling from library/node-exporter
49a2d53aa1af: Pull complete
3589a6efd9ce: Pull complete
190160031744: Pull complete
Digest: sha256:a2f29256e53cc3e0b64d7a472512600b2e9410347d53cdc85b49f659c17e02ee
Status: Downloaded newer image for harbor.example.com/library/node-exporter:v0.18.1
harbor.example.com/library/node-exporter:v0.18.1

That's all!