I tried to build a simple JS app in Jenkins Docker container locally and the build failed with:
script.sh: docker: not found (full stack trace is omitted for easier reading)
Here is Jenkinsfile
of the app:
pipeline {
agent { dockerfile true }
stages {
stage('Install') {
steps {
sh 'node -v '
sh 'yarn -v'
sh 'ember -v'
}
}
}
}
Here is Dockerfile
of the app:
FROM node:12
RUN curl -o- -L https://yarnpkg.com/install.sh | bash
RUN npm install -g ember-cli
What am I missing? Thank you.
You're missing the docker client on your Jenkins nodes.
If you're running Jenkins as docker container, you have to install Docker inside it as well.
This Dockerfile will use a Jenkins container as a base image and then install the docker client , So that it can communicate with the docker daemon.
from jenkinsci/jenkins:lts
USER root
RUN apt-get update -qq \
&& apt-get install -qqy apt-transport-https ca-certificates curl gnupg2 software-properties-common
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
RUN add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) \
stable"
RUN apt-get update -qq \
&& apt-get install docker-ce=17.12.1~ce-0~debian -y
RUN usermod -aG docker jenkins
Or if you're installing Jenkins in another way, you still have to install Docker on Jenkins node.
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.