0

I have installed Jenkins and docker in same machine Ubuntu.

  • Ubuntu 17.10
  • Jenkins ver. 2.73.3
  • Docker version 17.09.0-ce.

I am trying to set up jenkin docker containers as slaves for running my automation test suite.

I was able to correctly, setup the docker plugin in Jenkins for spinning up docker containers and added a docker template with a image that i created for setting up docker enviroment.

The image has been built on docker hosted in Ubuntu.

Problem is now when i run a job from Jenkins. It gives a error message (pending—Jenkins doesn’t have label docker-slave)

Jenkins pending image

When I check the Jenkins logs in Ubuntu machine I see the following error message

com.github.dockerjava.api.exception.NotFoundException: {"message":"pull access 
denied, "message":may require 'docker login'"}

In the ubuntu machine, i have already given done docker login.

The image that i am trying to build containers from is locally on ubuntu, not pushed to any repository, so why is trying to pull the image.

Also, what is the permission issue that i need to resolve. When build a job, from jenkins, its the jenkins user building the container. Do I need to add something else there.

user1555608
  • 5
  • 1
  • 7

2 Answers2

0

In your Jenkinsfile you can use credentials with the credentials plugin:

    // Login to registry
    withCredentials([usernamePassword(credentialsId: 'YOUR_ID_AD_DEFINED_IN_JENKINS', passwordVariable: 'PASS', usernameVariable: 'USER')]) {
        sh "docker login --username=$USER --password=$PASS your.registry.here.com"
    }

    // Build with correct pom version
    sh "docker build -t your.registry.here.com/your_image_here/your_image_name:${POM_VERSION} ."

    // Push
    sh "docker push your.registry.here.com/your_image_here/your_image_name:${POM_VERSION}"

    //pull
    sh "docker pull your.registry.here.com/your_image_here/your_image_name:${POM_VERSION}"

The ${POM_VERSION} is just a rip from my own code and can ofcourse be any version you like

you also need to define the credentials in your Jenkins server. A description can be found here Working with jenkins credentials

Ivonet
  • 2,492
  • 2
  • 15
  • 28
  • thanks @Ivonet for the response. Which Jenkinsfile are you referring to. I do not have any specific jenkins file in my configuration. – user1555608 Dec 11 '17 at 17:47
  • Ah that was an assumption of mine, sorry. Then I would promote start using one :-) This way you can configure Jenkins from within your project. – Ivonet Dec 11 '17 at 17:53
-1

Check your docker template configuration and select "Never pool" for "pool strategy".