Using a custom registry instead of default dockerhub registry

0 votes

I am using the docker plugin in jenkins for jenkins-docker integration, i am using a scripted pipeline in my project. I don't want to use the dockerhub which is the default registry that comes with the docker plugin.How do i configure to use a custom registry instead?

Jul 9, 2019 in Docker by Sam
• 6,260 points
1,103 views

1 answer to this question.

0 votes

By default the "Docker pipeline" integrates assumes the default Docker Registry of Docker Hub.

In order to use a custom Docker Registry, users of Scripted Pipeline can wrap steps with the withRegistry() method, passing in the custom Registry URL, for example:
 

node {
    checkout scm

    docker.withRegistry('https://registry.example.com') {

        docker.image('my-custom-image').inside {
            sh 'make test'
        }
    }
}

For a Docker Registry which requires authentication, add a "Username/Password" Credentials item from the Jenkins home page and use the Credentials ID as a second argument to withRegistry():
 

node {
    checkout scm

    docker.withRegistry('https://registry.example.com', 'credentials-id') {

        def customImage = docker.build("my-image:${env.BUILD_ID}")

        /* Push the container to the custom Registry */
        customImage.push()
    }
}
answered Jul 9, 2019 by Sirajul
• 59,230 points

Related Questions In Docker

0 votes
1 answer
0 votes
2 answers
0 votes
1 answer
0 votes
2 answers

How can I inspect the file system of a failed `docker build

Failed command is a build that has ...READ MORE

answered Aug 6, 2018 in Docker by Nilesh
• 7,060 points
3,131 views
+2 votes
1 answer
+2 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 58,020 points
2,714 views
0 votes
1 answer

How do I create a service using an image from a private registry?

Hey @Ruby, If your image is available ...READ MORE

answered Jul 8, 2019 in Docker by Sirajul
• 59,230 points
1,073 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP