0

I have two endpoints for my registry (Nexus OSS):

Endpoint 10500 to pull images from.

And Endpoint 10501 to push images to.

(I can go into detail what the idea is and why we think Nexus requires this if need be. I might have Nexus configured wrongly after all. But I am currently thinking it's correct.)

Jenkinsfile has:

docker.withRegistry(myRegistry:10501, 'nexus_jenkins_user') {
    docker.build(imageToBuild.getName(), '-f ' + imageToBuild.tag + '.Dockerfile .').push();
}

Dockerfile has

FROM myRegistry:10500/myNamespace/core:latest
...

Jenkins execution reports the following error:

docker build -t myNamespace/php:php.7.2 -f php.7.2.Dockerfile .

Sending build context to Docker daemon   80.9kB

...

Step 1/7 : FROM myRegistry:10500/myNamespace/core:latest

Get https://myRegistry:10500/v2/myNamespace/core/manifests/latest: no basic auth credentials

script returned exit code 1

This seems obvious as the "withRegistry" directive above has the 10501 endpoint, so there would be no authentication for the 10500 endpoint here.

The challenge: I need to be able to pull the core image (through 10500) but push the finished image to 10501.

What would my Jenkinsfile need to look like to achieve this?

This should theoretically be a common problem for companies utilizing Nexus OSS as they will have two endpoints as well. (Assuming I am correct about Nexus requiring two endpoints if a hosted repo and a proxy repo are being used).

edit To provide some help for understanding: If I specify

FROM myRegistry:10501/myNamespace/core:latest

in my Dockerfile, authentication will work as "withRegistry" and the Dockerfile's FROM directive are set to the same endpoint.

But I want all pulling actions to go through 10500. If, for example, I would use an image from Docker Hub, 10500 would pull it from Hub, cache it and deliver it back to me, where 10501 would not. So 10500 needs to be used for all pulling.

1

Try to chain withRegistry like this:

docker.withRegistry('https://registry:10500', 'credentials-id') {
    docker.withRegistry('https://registry:10501', 'credentials-id') {
        docker.build(imageToBuild.getName(), '-f ' + imageToBuild.tag + '.Dockerfile .').push();
    }
}
| improve this answer | |
  • Sadly this doesn't have any effect. It doesn't even give me a different message. Just seems to treat it the exact same way as before. Like the first "withRegistry" does not have any effect. – Worp Nov 7 '19 at 18:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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