简体   繁体   中英

Jenkins Docker Pipelining inside Docker

I'm following along with this tutorial:

https://www.linkedin.com/pulse/building-docker-pipeline-cloudbees-jenkins-jay-johnson

I'm running Jenkins on Docker 17:

docker run -d -p 8080:8080 -p 50000:50000 --name jenkins jenkins

I followed the instructions and replaced Jay's credentials with my own. I added my creds to Global and then renamed the creds in the pipeline script. When I attempt the build, though I'm getting the following error:

Proceeding
[Pipeline] withEnv
[Pipeline] {
[Pipeline] withDockerRegistry
Wrote authentication to /var/jenkins_home/.dockercfg
[Pipeline] {
[Pipeline] stage (Building)
Using the ‘stage’ step without a block argument is deprecated
Entering stage Building
Proceeding
[Pipeline] sh
[alfred-master] Running shell script
+ docker build -t jayjohnson/django-slack-sphinx:testing django
/var/jenkins_home/workspace/alfred-master@tmp/durable-713ce0d7/script.sh: 2: /var/jenkins_home/workspace/alfred-master@tmp/durable-713ce0d7/script.sh: docker: not found
[Pipeline] }
[Pipeline] // withDockerRegistry
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 127
Finished: FAILURE

I'm assuming this is looking for the docker binary.

How can I build a docker image from a repo from inside a Docker container?

The issue is here:

/var/jenkins_home/workspace/alfred-master@tmp/durable-713ce0d7/script.sh: 2: /var/jenkins_home/workspace/alfred-master@tmp/durable-713ce0d7/script.sh: docker: not found

I'm assuming your build is running on the master instance, which is just a basic installation of Jenkins - no extra tools.

You'll want to run an agent slave and connect it to your master - this agent should ensure it has Docker installed, and then you will be able to run those commands.

You can either set this up yourself; or use an open source option - Currently in my own setup I'm using this image which has everything I need (Well, personally - I've forked it and added some of my own tools as well).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM