I need to cache docker images while pulling from the docker hub in my Harbor "Proxy Cache " project. Therefore I have configured a project with an option Proxy Cache. The registries section also added a new registry endpoint with a provider as "Docker Hub." I added the following configuration to the docker daemon.
cat /etc/docker/daemon.json
{
"registry-mirrors": ["https://registry.harbor.com"]
}
While I'm pulling images from the docker hub it is not caching on my harbor project. Need help to resolve this issue and how my request fulfills with the harbor.
example
my cache project name = proxy
i need to pull httpd:latest
This method not working also
At the time of answering this question originally, there wasn't a good solution. You can read my original answer. Or just scroll down to the update section where I tell you that Harbor v2.1's blog says they now support this.
Original Answer
I can answer part of your problem. But the answer to part 2 is that you can't. I can link you the issue to show you that they explicitly chose not to due to technical limitations. The good news is that they are aware that this is still somethign that the community wants.
Part 1
One thing you may not know, repos on hub.docker that do not have a project group (like
docker pull nginx
), still need a project in your harbor that match. It will match on the project namelibrary
. So make sure you have a project namedlibrary
. Not having thislibrary
project probably wont effect pass through caching but it definately effects replication.My setup contains: harbor url:
harbor.mydomain.com
project:
I got my pulls to work with the following example:
Remember, for something like
docker pull ngninx
, you have to do it as if it were actuallylibrary/nginx
When I look in projects/cache_proxy-hub-docker I see:
Please also remember, the pull command with the prefix, is also going to be what that image will be known as on your machine after the pull. You'll have to retag it to what you're expecting it to really be. That's why the docker daemon solution is so appealing...
Part 2
I ran around on this same issue. Finally, I suspected they didn't implement it this way. That is correct:
https://github.com/goharbor/harbor/issues/8082#issuecomment-698012277
question:
answer:
UPDATE
The Harbor blog for v2.1 indicates that they have now fully added this feature. My answer above is accurate for versions prior to 2.1. I haven't personally tested this but I will link the blog post talking about it.
Blog: https://goharbor.io/blog/harbor-2.1/