Issue getting Docker Pipeline plugin to build an image

131 views
Skip to first unread message

Lyle Dietz

unread,
Jun 8, 2016, 1:23:43 AM6/8/16
to Jenkins Users
I'm having issues trying to build a Docker image with the Docker Pipeline plugin.

I've tried searching, but no-one seems to be having the issue, and all the documentation I see suggests I'm not doing anything stupid.

My current Jenkins file is as follows (I've pared it back for simplicity/debugging):

----
#!groovy

node {
  stage 'checkout'
  checkout scm

  stage 'build'
  def image = docker.build('openshift/wildfly:10')
}
----

The output from the job is:
----
Started by user Lyle Dietz
Cloning the remote Git repository
 > git init /home/jenkins/.jenkins/workspace/wildfly@script # timeout=10
 > git --version # timeout=10
using .gitcredentials to set credentials
 > git config --local credential.username jenkins # timeout=10
 > git config --local credential.helper store --file=/tmp/git2241825672262408901.credentials # timeout=10
 > git -c core.askpass=true fetch --tags --progress http://gitblit.myorg.local/r/experiments/openshift/wildfly.git +refs/heads/*:refs/remotes/origin/*
 > git config --local --remove-section credential # timeout=10
 > git config remote.origin.url http://gitblit.myorg.local/r/experiments/openshift/wildfly.git # timeout=10
 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git config remote.origin.url http://gitblit.myorg.local/r/experiments/openshift/wildfly.git # timeout=10
using .gitcredentials to set credentials
 > git config --local credential.username jenkins # timeout=10
 > git config --local credential.helper store --file=/tmp/git4715501803936103145.credentials # timeout=10
 > git -c core.askpass=true fetch --tags --progress http://gitblit.myorg.local/r/experiments/openshift/wildfly.git +refs/heads/*:refs/remotes/origin/*
 > git config --local --remove-section credential # timeout=10
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 4e21d6895f1505810a35774f7ee6e339658c8252 (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 4e21d6895f1505810a35774f7ee6e339658c8252
 > git rev-list 4e21d6895f1505810a35774f7ee6e339658c8252 # timeout=10
[Pipeline] node
Running on master in /home/jenkins/.jenkins/workspace/wildfly
[Pipeline] {
[Pipeline] stage (checkout)
Entering stage checkout
Proceeding
[Pipeline] checkout
Cloning the remote Git repository
 > git init /home/jenkins/.jenkins/workspace/wildfly # timeout=10
 > git --version # timeout=10
using .gitcredentials to set credentials
 > git config --local credential.username jenkins # timeout=10
 > git config --local credential.helper store --file=/tmp/git5568879933463267023.credentials # timeout=10
 > git -c core.askpass=true fetch --tags --progress http://gitblit.myorg.local/r/experiments/openshift/wildfly.git +refs/heads/*:refs/remotes/origin/*
 > git config --local --remove-section credential # timeout=10
 > git config remote.origin.url http://gitblit.myorg.local/r/experiments/openshift/wildfly.git # timeout=10
 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git config remote.origin.url http://gitblit.myorg.local/r/experiments/openshift/wildfly.git # timeout=10
using .gitcredentials to set credentials
 > git config --local credential.username jenkins # timeout=10
 > git config --local credential.helper store --file=/tmp/git695409405329882652.credentials # timeout=10
 > git -c core.askpass=true fetch --tags --progress http://gitblit.myorg.local/r/experiments/openshift/wildfly.git +refs/heads/*:refs/remotes/origin/*
 > git config --local --remove-section credential # timeout=10
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 4e21d6895f1505810a35774f7ee6e339658c8252 (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 4e21d6895f1505810a35774f7ee6e339658c8252
[Pipeline] stage (build)
Entering stage build
Proceeding
[Pipeline] node
Running on master in /home/jenkins/.jenkins/workspace/wildfly@2
[Pipeline] {
[Pipeline] sh
[wildfly@2] Running shell script
+ docker build -t openshift/wildfly:10 .
time="2016-06-08T14:53:04+10:00" level=fatal msg="Cannot locate Dockerfile: Dockerfile" 
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE
----

and after the build fails the workspace directory looks thusly:

----
# tree workspace/
workspace/
├── wildfly
│   ├── Dockerfile
│   └── Jenkinsfile
├── wildfly@2
├── wildfly@2@tmp
└── wildfly@script
    ├── Dockerfile
    └── Jenkinsfile

4 directories, 4 files
----

I don't understand why the directories with '@' are being created. Shouldn't this be running in the workspace? If not, how do I get my code checked out in to the directory that the docker build will run in?

Now matter how I try to do this, the docker build step _always_ creates a new directory.

I'd appreciate any help with this, I'm starting to feel rather stupid :( .

Michael Neale

unread,
Jun 8, 2016, 10:23:49 PM6/8/16
to Jenkins Users
Try not to feel stupid ;)

The @ directories I believe due to locking - when a direcotry is locked and a step or a build wants to run in there, it appends a number, but I don't think that is your problem. 

Docker pipeline bind mounts in the workspace, so perhaps how your daemon is running vs the slave don't line up - this can be the case on OSX/windows (pre the "new" docker beta which uses more native virtialisation on osx). 

Can get the docker image to build if you run "sh 'docker build -t openshift/wildfly:10 .' ? 

Lyle Dietz

unread,
Jun 9, 2016, 12:38:10 AM6/9/16
to Jenkins Users
I don't feel stupid anymore, I feel like I'm going insane.

I just set up a brand new VM and the exact same repository builds. Maybe I need a holiday.

On the original VM I didn't have any issues with building when using a shell command.

Michael Neale

unread,
Jun 9, 2016, 12:49:59 AM6/9/16
to Jenkins Users
Sanity - well that is much more serious ;)

OK, well new VM to me implies it was to do with the forever problematic bind mounting and docker (perhaps users and permissions), although this normally shows up with ".inside" not so much with build that I have seen. 

The original worked fine when using "sh 'docker build..." inside a pipeline script? 

Lyle Dietz

unread,
Jun 9, 2016, 1:13:06 AM6/9/16
to Jenkins Users
> The original worked fine when using "sh 'docker build..." inside a pipeline script?

Yeah, I used that to confirm there wasn't some problem with the daemon because I was starting to get paranoid. 

---

sh 'docker build -t openshift/wildfly:10 .'
---

Works just fine.

Mind you, the VM I installed it on was brand new as well. I'm thinking that perhaps I should re-install it, or blow away the Jenkins installation and start again.

Lyle Dietz

unread,
Jun 9, 2016, 2:34:18 AM6/9/16
to Jenkins Users
I've made progress, it only happens when I get Upstart to start Jenkins. If I start Jenkins from within a byobu session it works fine.

I'm guessing it has something to do with the environment. Now I just have to track down what that difference is.

Michael Neale

unread,
Jun 9, 2016, 9:55:05 PM6/9/16
to Jenkins Users
Right - I haven't used upstart for some time, but if it is like systemd, it may be placing constraints on child processes (like app armour) that prevent certain things from working. 

In the log for the build you should see the actual command used to build the image, might be worth noting if it looks any different to what you would run yourself. 
Reply all
Reply to author
Forward
0 new messages