[英]How to install docker properly in Jenkins?
I'm running jenkins/jenkins
image from dockerhub, I've installed the docker plugin, still not able to find docker inside a pipeline, what am i missing我正在从 dockerhub 运行
jenkins/jenkins
图像,我已经安装了 docker 插件,但仍然无法在管道内找到 docker,我错过了什么
pipeline {
agent any
stages {
stage('Running') {
agent {
docker {
image 'node:14-alpine'
}
}
steps {
echo 'preparing the flow'
}
}
stage('Build') {
agent {
docker {
image 'node:14-alpine'
}
}
steps {
sh """
npm install
"""
}
}
}
}
/var/jenkins_home/workspace/multibranch_PR-1@2@tmp/durable-5bf3a454/script.sh: 1: /var/jenkins_home/workspace/multibranch_PR-1@2@tmp/durable-5bf3a454/script.sh: docker: not found
[Pipeline] isUnix
[Pipeline] sh
+ docker inspect -f . hub.docker.com/node:14-alpine
/var/jenkins_home/workspace/multibranch_PR-1@2@tmp/durable-dea9bcb7/script.sh: 1: /var/jenkins_home/workspace/multibranch_PR-1@2@tmp/durable-dea9bcb7/script.sh: docker: not found
[Pipeline] isUnix
[Pipeline] sh
+ docker pull hub.docker.com/node:14-alpine
/var/jenkins_home/workspace/multibranch_PR-1@2@tmp/durable-b25ea3a8/script.sh: 1: /var/jenkins_home/workspace/multibranch_PR-1@2@tmp/durable-b25ea3a8/script.sh: docker: not found
The plugin is only a utility layer to use docker from your pipelines it does not install docker and still needs access to the docker socket.该插件只是一个实用程序层,用于从您的管道中使用 docker,它不安装 docker,仍然需要访问 docker 套接字。
Generally there a two ways to achieve this.通常有两种方法可以实现这一点。 Install docker inside the jenkins container (with apt) or mount the docker socket of the host inside the container.
在 jenkins 容器内安装 docker(使用 apt)或者在容器内挂载宿主机的 docker socket。 For the latter you can follow this
对于后者,你可以按照这个
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.