[JIRA] (JENKINS-39664) Docker builds do not work with Kubernetes Pipeline plugin

26 views
Skip to first unread message

triplem@devopsku.be (JIRA)

unread,
Nov 11, 2016, 2:52:01 AM11/11/16
to jenkinsc...@googlegroups.com
Markus May created an issue
 
Jenkins / Bug JENKINS-39664
Docker builds do not work with Kubernetes Pipeline plugin
Issue Type: Bug Bug
Assignee: Ioannis Canellos
Components: docker-workflow-plugin, kubernetes-pipeline-plugin
Created: 2016/Nov/11 7:51 AM
Environment: Jenkins 2.19.1
Kubernetes-Pipeline-Plugin 0.9
Docker-Workflow-Plugin 1.9
Priority: Major Major
Reporter: Markus May

I have setup a Kubernetes Pipeline (see below) which is working fine, as long as I do use shell-scripts to generate the Docker-Image. As soon as I try to use the docker-Workflow plugin, the script comes back, with an exception in a (not defined by myself) dockerFingerprintFrom-step. This step does not seem to be able to find the generated docker-image anymore. Therefor I do assume, that this step is then not run in the container, where I build the image.

Any help is appreciated.

Unable to find source-code formatter for language: groovy. Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml
podTemplate(label: 'docker-mysql', containers: [
    containerTemplate(name: 'docker', image: 'docker:1.12.3-dind', ttyEnabled: true, command: 'cat', privileged: true, instanceCap: 1),
    containerTemplate(name: 'jnlp', image: 'jenkinsci/jnlp-slave:2.62-alpine', args: '${computer.jnlpmac} ${computer.name}'),
  ],
  volumes: [
        hostPathVolume(mountPath: "/var/run/docker.sock", hostPath: "/var/run/docker.sock")
  ]) {
  node() {
    stage('Preparation') { // for display purposes
      git url: 'https://github.com/devopskube/docker-mysql.git'
      container('docker') {
        stage('Build the docker image') {

        sh 'docker build -t devopskube/mysql:latest .'
        sh 'docker inspect -f {{.Id}} devopskube/mysql:latest'

        id = sh (
              script: 'docker inspect -f {{.Id}} devopskube/mysql:latest',
              returnStdout: true
             ).trim()
        }
      }
    }
  }
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)
Atlassian logo

triplem@devopsku.be (JIRA)

unread,
Nov 11, 2016, 2:58:01 AM11/11/16
to jenkinsc...@googlegroups.com
Markus May updated an issue
Change By: Markus May
I have setup a Kubernetes Pipeline (see below) which is working fine, as long as I do use shell-scripts to generate the Docker-Image. As soon as I try to use the docker-Workflow plugin, the script comes back, with an exception in a (not defined by myself) dockerFingerprintFrom-step. This step does not seem to be able to find the generated docker-image anymore. Therefor I do assume, that this step is then not run in the container, where I build the image.

Any help is appreciated.

{code:groovy}

podTemplate(label: 'docker-mysql', containers: [
    containerTemplate(name: 'docker', image: 'docker:1.12.3-dind', ttyEnabled: true, command: 'cat', privileged: true, instanceCap: 1),
    containerTemplate(name: 'jnlp', image: 'jenkinsci/jnlp-slave:2.62-alpine', args: '${computer.jnlpmac} ${computer.name}'),
  ],
  volumes: [
        hostPathVolume(mountPath: "/var/run/docker.sock", hostPath: "/var/run/docker.sock")
  ]) {
  node() {
    stage('Preparation') { // for display purposes
      git url: 'https://github.com/ devopskube repo /docker-mysql.git'

      container('docker') {
        stage('Build the docker image') {

        sh 'docker build -t devopskube/mysql:latest .'
        sh 'docker inspect -f {{.Id}} devopskube repo /mysql:latest'

        id = sh (
              script: 'docker inspect -f {{.Id}}
devopskube repo /mysql:latest',
              returnStdout: true
             ).trim()
        }
      }
    }
  }
{code}

iocanel@gmail.com (JIRA)

unread,
Nov 11, 2016, 3:16:01 AM11/11/16
to jenkinsc...@googlegroups.com
Ioannis Canellos commented on Bug JENKINS-39664
 
Re: Docker builds do not work with Kubernetes Pipeline plugin

We need more details in order to identify the problem and help. If I understand correctly the script you pasted is something that works. Can you please paste that fails? Also can you please provide the full stack trace.

triplem@devopsku.be (JIRA)

unread,
Nov 11, 2016, 3:54:02 AM11/11/16
to jenkinsc...@googlegroups.com

Sure, the folllowing script does give the following "output":

Unable to find source-code formatter for language: groovy. Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml
+ docker build -t devopskube/mysql .
Sending build context to Docker daemon 13.31 kB

/home/jenkins/workspace/docker-mysql # exit
<snip>
Here the build of the docker image happens...
</snap>
Successfully built 8c3d46bc959b
[Pipeline] dockerFingerprintFrom
Executing shell script inside container [docker] of pod [kubernetes-1d1bed95d3ea4665b3bf13e07380c7b0-12552de6d1a]
Executing command: docker inspect -f {{.Id}} devopskube/mysql 
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // container
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // podTemplate
[Pipeline] End of Pipeline
java.io.IOException: Cannot retrieve .Id from 'docker inspectdevopskube/mysql'
	at org.jenkinsci.plugins.docker.workflow.client.DockerClient.inspectRequiredField(DockerClient.java:190)
	at org.jenkinsci.plugins.docker.workflow.FromFingerprintStep$Execution.run(FromFingerprintStep.java:115)
	at org.jenkinsci.plugins.docker.workflow.FromFingerprintStep$Execution.run(FromFingerprintStep.java:75)
	at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:52)
	at hudson.security.ACL.impersonate(ACL.java:221)
	at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:49)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Finished: FAILURE

The script is just slightly adopted:

Unable to find source-code formatter for language: groovy. Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml
podTemplate(label: 'docker-mysql', containers: [
    containerTemplate(name: 'docker', image: 'docker:1.12.3-dind', ttyEnabled: true, command: 'cat', privileged: true, instanceCap: 1),
    containerTemplate(name: 'jnlp', image: 'jenkinsci/jnlp-slave:2.62-alpine', args: '${computer.jnlpmac} ${computer.name}'),
  ],
  volumes: [
        hostPathVolume(mountPath: "/var/run/docker.sock", hostPath: "/var/run/docker.sock")
  ]) {
  node() {
    stage('Preparation') { // for display purposes
      git url: 'https://github.com/devopskube/docker-mysql.git'
      container('docker') {
        stage('Build the docker image') {

          docker.build('devopskube/mysql')
        
        }
      }
    }
  }
}

triplem@devopsku.be (JIRA)

unread,
Nov 11, 2016, 4:14:02 AM11/11/16
to jenkinsc...@googlegroups.com
Markus May edited a comment on Bug JENKINS-39664
Sure, the folllowing script does give the following "output":


{code:groovy}
[Pipeline] podTemplate
[Pipeline] {
[Pipeline] node
Running on kubernetes-1d1bed95d3ea4665b3bf13e07380c7b0-12552de6d1a in /home/jenkins/workspace/docker-mysql
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Preparation)
[Pipeline] git
Cloning the remote Git repository
Cloning repository https://github.com/devopskube/docker-mysql.git
> git init /home/jenkins/workspace/docker-mysql # timeout=10
Fetching upstream changes from https://github.com/devopskube/docker-mysql.git
> git --version # timeout=10
> git fetch --tags --progress https://github.com/devopskube/docker-mysql.git
+ refs/heads/*:refs/remotes/origin/*
> git config remote.origin.url https://github.com/devopskube/
docker -mysql.git # timeout=10
> git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
> git config remote.origin.url https://github.com/devopskube/docker-mysql.git # timeout=10
Fetching upstream changes from https://github.com/devopskube/docker-mysql.git
> git fetch --tags --progress https://github.com/devopskube/docker-mysql.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 73d040979d4faeb597ddcc8d80198eb0bdddfd2c (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f 73d040979d4faeb597ddcc8d80198eb0bdddfd2c
> git branch -a -v --no-abbrev # timeout=10
> git checkout -b master 73d040979d4faeb597ddcc8d80198eb0bdddfd2c
> git rev-list 73d040979d4faeb597ddcc8d80198eb0bdddfd2c # timeout=10
[Pipeline] container
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Build the docker image)
[Pipeline] sh
[docker-mysql] Running shell script

Executing shell script inside container [docker] of pod [kubernetes-1d1bed95d3ea4665b3bf13e07380c7b0-12552de6d1a]
Executing command: sh -c echo $$ > '/home/jenkins/workspace/docker-mysql@tmp/durable-1dc92f56/pid'; jsc=durable-27d97ad1c907eb144d854b5bac745183; JENKINS_SERVER_COOKIE=$jsc '/home/jenkins/workspace/docker-mysql@tmp/durable-1dc92f56/script.sh' > '/home/jenkins/workspace/docker-mysql@tmp/durable-1dc92f56/jenkins-log.txt' 2>&1; echo $? > '/home/jenkins/workspace/docker-mysql@tmp/durable-1dc92f56/jenkins-result.txt'
/home/jenkins # [6ncd /home/jenkins/workspace/docker-mysql
/home/jenkins/workspace/docker-mysql # sh -c echo $$ > '/home/jenkins/workspace/

docker-mysql@tmp/durable-1dc92f56/pid'; jsc=durable-27d97ad1c907eb144d854b5bac74

5183; JENKINS_SERVER_COOKIE=$jsc '/home/jenkins/workspace/docker-mysql@tmp/durab

le-1dc92f56/script.sh' > '/home/jenkins/workspace/docker-mysql@tmp/durable-1dc92

f56/jenkins-log.txt' 2>&1; echo $? > '/home/jenkins/workspace/docker-mysql@tmp/d

urable-1dc92f56/jenkins-result.txt'
+ docker
build -t devopskube/mysql .

Here the
build of the docker image happens...
{code}


The script is just slightly adopted:

{code:groovy}

podTemplate(label: 'docker-mysql', containers: [
    containerTemplate(name: 'docker', image: 'docker:1.12.3-dind', ttyEnabled: true, command: 'cat', privileged: true, instanceCap: 1),
    containerTemplate(name: 'jnlp', image: 'jenkinsci/jnlp-slave:2.62-alpine', args: '${computer.jnlpmac} ${computer.name}'),
  ],
  volumes: [
        hostPathVolume(mountPath: "/var/run/docker.sock", hostPath: "/var/run/docker.sock")
  ]) {
  node() {
    stage('Preparation') { // for display purposes
      git url: 'https://github.com/devopskube/docker-mysql.git'
      container('docker') {
        stage('Build the docker image') {

          docker.build('devopskube/mysql')
        
        }
      }
    }
  }
}
{code}

iocanel@gmail.com (JIRA)

unread,
Nov 11, 2016, 4:52:01 AM11/11/16
to jenkinsc...@googlegroups.com

I tried the script locally and I noticed a couple of things:

  1. node doesn't specify a label. Might not be a problem, but you'd better refer to the podTemplate's label: node('docker-mysql').
  2. container('docker') should be container(name: 'docker'). In my env this gives an error.
  3. I had to change the version of the docker image, to align with my docker server.

If none of these, help I would check the version of the docker workflow plugin.

iocanel@gmail.com (JIRA)

unread,
Nov 11, 2016, 4:58:01 AM11/11/16
to jenkinsc...@googlegroups.com

Sorry, I was wrong. In my environment the image is built, but I do get a similar error, in the end.
It seems that this is more of a docker workflow issue, so I can't do much here.

triplem@devopsku.be (JIRA)

unread,
Nov 11, 2016, 5:34:01 AM11/11/16
to jenkinsc...@googlegroups.com

Uh, okay. I have done all the mentioned changes, and still get the error. I even un-installed the "normal" docker-plugin and the docker-step-plugin, still to no avail. Whom should I assign this issue to?

iocanel@gmail.com (JIRA)

unread,
Nov 11, 2016, 5:51:01 AM11/11/16
to jenkinsc...@googlegroups.com
Ioannis Canellos assigned an issue to Jesse Glick
 
Change By: Ioannis Canellos
Assignee: Ioannis Canellos Jesse Glick

iocanel@gmail.com (JIRA)

unread,
Nov 11, 2016, 5:52:04 AM11/11/16
to jenkinsc...@googlegroups.com
Ioannis Canellos commented on Bug JENKINS-39664
 
Re: Docker builds do not work with Kubernetes Pipeline plugin

I assigned it to Jesse Glick. He would know better if this needs to be assigned to someone else.

jglick@cloudbees.com (JIRA)

unread,
Nov 15, 2016, 7:41:01 AM11/15/16
to jenkinsc...@googlegroups.com
Jesse Glick assigned an issue to Ioannis Canellos
 

Not me.

Change By: Jesse Glick
Component/s: docker-workflow-plugin
Assignee: Jesse Glick Ioannis Canellos

iocanel@gmail.com (JIRA)

unread,
Nov 15, 2016, 7:52:01 AM11/15/16
to jenkinsc...@googlegroups.com
 
Re: Docker builds do not work with Kubernetes Pipeline plugin

Jesse Glick Can you please tell me, why you think that this is not related to the docker workflow plugin? It might help determine what's the actual cause.

jglick@cloudbees.com (JIRA)

unread,
Nov 15, 2016, 9:34:01 AM11/15/16
to jenkinsc...@googlegroups.com

If there is something that can be reproduced with only docker-workflow installed then reassign with details.

triplem@devopsku.be (JIRA)

unread,
Nov 17, 2016, 7:47:01 AM11/17/16
to jenkinsc...@googlegroups.com

Hi, me just would like to get some help to resolve this issues.

@jglick: Could you Tell me, unser what circumstances the dockerFingerprintFrom is executed? Could I increase the Loglevel to gather the reason for the above mentioned exception?

triplem@devopsku.be (JIRA)

unread,
Nov 17, 2016, 6:00:02 PM11/17/16
to jenkinsc...@googlegroups.com

Ioannis Canellos hm, I guess me is using the Kubernetes Plugin and not the Kubernetes Pipeline Plugin. Could you please ask this maintainer vor help?

triplem@devopsku.be (JIRA)

unread,
Nov 19, 2016, 10:56:04 AM11/19/16
to jenkinsc...@googlegroups.com

I have now tried to fetch some additional information from the DockerClient. I do get the information, that the statusCode is "1" (error), but unfortunately both stderr as well as stdout are empty.

Jesse Glick: you sure, that this is not an issue in the docker pipeline plugin? Since the command I do execute is working properly if executed directly (via sh, that is), this seems to be quite obvious.

Any hints on additional debug possibilities?

jglick@cloudbees.com (JIRA)

unread,
Nov 23, 2016, 1:26:01 PM11/23/16
to jenkinsc...@googlegroups.com

Could you Tell me, unser what circumstances the dockerFingerprintFrom is executed?

When that step is run, which some parts of Docker.groovy do (IIRC the build method). Not sure how this is related to the Kubernetes plugin, unless that calls docker as a helper, in which case there should be a way to reproduce from scratch without the Kubernetes plugin.

iocanel@gmail.com (JIRA)

unread,
Nov 23, 2016, 2:04:01 PM11/23/16
to jenkinsc...@googlegroups.com

Jesse Glick the kubernetes-plugin doesn't use docker in any way (neither binary, nor client, plugin etc). But, if the user wants to use docker within the slave pod (like this case), he would have to tell the kuberntes-plugin, what volumes to mount (e.g. the docker socket) and what env vars to use to talk to docker. Since the docker build part seems to work ok, I can only assume that Markus May configured that correctly.

triplem@devopsku.be (JIRA)

unread,
Dec 30, 2016, 4:13:01 AM12/30/16
to jenkinsc...@googlegroups.com

Should I provide any additional information?

electroma@gmail.com (JIRA)

unread,
Jan 23, 2017, 5:16:03 PM1/23/17
to jenkinsc...@googlegroups.com

Same issue with kubernetes-plugin 0.10.
docker.build "myimage" fails, but if i replace it to sh 'docker build -t myimage .' it works.

jenkins-ci@carlossanchez.eu (JIRA)

unread,
Mar 13, 2017, 4:16:02 AM3/13/17
to jenkinsc...@googlegroups.com
Carlos Sanchez updated an issue
 
Change By: Carlos Sanchez
Component/s: kubernetes-plugin
Component/s: kubernetes-pipeline-plugin
This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

michael@macfadden.org (JIRA)

unread,
Feb 18, 2018, 4:52:02 PM2/18/18
to jenkinsc...@googlegroups.com
Michael MacFadden commented on Bug JENKINS-39664
 
Re: Docker builds do not work with Kubernetes Pipeline plugin

Just ran into this as well. Any of the command using "docker." don't seem to work. I had to revert to using "sh".

jenkins-ci@carlossanchez.eu (JIRA)

unread,
Feb 19, 2018, 4:12:02 AM2/19/18
to jenkinsc...@googlegroups.com
Carlos Sanchez updated an issue
Change By: Carlos Sanchez
Component/s: docker-workflow-plugin

jenkins-ci@carlossanchez.eu (JIRA)

unread,
May 17, 2018, 11:55:05 AM5/17/18
to jenkinsc...@googlegroups.com

jenkins-ci@carlossanchez.eu (JIRA)

unread,
May 25, 2018, 5:23:02 AM5/25/18
to jenkinsc...@googlegroups.com
Carlos Sanchez started work on Bug JENKINS-39664
 
Change By: Carlos Sanchez
Status: Open In Progress
Reply all
Reply to author
Forward
0 new messages