6

So,

We are going to setup local proxy repository. Which directs to further docker hub and our another remote Docker Hosted repository hosted on different location.Which is requested through Docker(group) in Nexus.

I want to create a mirror for our remote repository which we are accessing through docker proxy in Nexus Repository manager in our local repository and caching its contents when somebody requests a image that is hosted in remote repository and next time when somebody fetches it he is served through local caching.

So if anybody pushes updated docker image on our remote repository it should be automatically mirrored in local repository

unlike when somebody requests updated image then local cache is invalidated and request again goes to remote repository for fetching the updated image.

Bottom line.

How to do docker repository mirroring between two repository manager based on Nexus version i mentioned in question or any other way?

Any help appreciated.Thank you

1 Answer 1

5

In Nexus, go to the Admin Backend.

Create a blob store if you haven't already. Guidance can be found here: https://help.sonatype.com/repomanager3/configuration/repository-management#RepositoryManagement-BlobStores

Once you have a blob store, continue like so:

Choose "Repositories", hit "Create Repository". Choose "docker (proxy)" as the recipe.

Give it any name (for example "docker-hub").

Under "Remote storage" enter https://registry-1.docker.io.

As "Docker Index" select Use Docker Hub.

Select a blob store for it (which you have created above).

Hit "Create repository". No more configuration is needed for the proxy repo.

Next up: A group repository, from which you will pull:

Go back to "Repositories" and hit "Create repository" again. This time select "docker (group)".

Call it anything you like (for example "docker-group").

For "HTTPS" enter any port you like. (we have 10500)

For blob store select any blob store (for example the one you have created above).

Under "Group" select for "member repositories" the repository you have created above.

You can also add a "docker (hosted)" repository as well if you have one set up. (I will explain later)

Hit "Create repository".

Now open your Docker cli and do a pull of some Docker Hub image but don't pull it from Docker Hub, pull it through the HTTPs endpoint of your docker (group) repo that you have created above like so:

$ docker pull my.repository.com:10500/phpmyadmin/phpmyadmin

This will create a pull request to your Nexus OSS, which will proxy the request to Docker Hub. The image from Docker Hub will be cached in your Nexus and will be delivered to you.

After pulling browse your docker (proxy) repo that you have created above and check the images inside. You will find a phpmyadmin/phpmyadmin inside (or any other image you have checked out) with a current timestamp.

Hope that helps!

9
  • 1
    Thanks for your reply.But l believe I have done that already. I need automatic mirroring between 2 repositories.
    – Terminator
    Oct 31, 2019 at 8:48
  • Define "automatic" and "between 2 repositories" please. 2 Repositories as in "two repositories hosted on Nexus" or in "our nexus Proxy Repository and Docker Hub"? "Automatic" as in "pull EVERYTHING regularly and cache it"?
    – Worp
    Oct 31, 2019 at 9:07
  • Automatic as you defined latter.pull everything regularly just for remote repository and cache it in local repository. it can be anything may be running a job at night to replicate remote repository storage.
    – Terminator
    Oct 31, 2019 at 9:34
  • Do you have complete knowledge of the repository you want to completely mirror? Or are you talking about docker hub? I am asking because the only possible way I could come up with would be to have a cron job (or similar) run a pull request through your docker (proxy) nexus repo for every single image in the repository you want to mirror. But you'd need complete knowledge of all images there to do that.
    – Worp
    Oct 31, 2019 at 10:03
  • 1
    Thanks Worp for your valuable input. This seems to be leading to a solution and I will definitely try these things and will let you know about the outcome. Thanks :)
    – Terminator
    Oct 31, 2019 at 11:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.