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 in Docker by Sam
• 4,330 points
46 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 by Sirajul
• 40,980 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
• 6,920 points
108 views
0 votes
1 answer
0 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
• 56,960 points
251 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 in Docker by Sirajul
• 40,980 points
86 views