部署jenkins在k8s上
pipeline内容:
pipeline {
agent {
docker { image 'node:7-alpine' }
}
stages {
stage('Test') {
steps {
sh 'node --version'
}
}
}
}
报错:
+ docker inspect -f . node:7-alpine
/var/jenkins_home/workspace/0109deploy01@2@tmp/durable-4b089662/script.sh: 1: docker: not found
排查:
进入jenkins容器
kubectl exec -it -u root -n jenkins jenkins-56dfcc9456-h4kqs -- bash
进入后执行
docker -v
提示:
bash: docker: command not found
所以报错原因,在jenkins容器中没有安装docker
解决方案:
把docker 配置到容器中,在jenkins的yaml中添加以下内容文章来源:https://www.toymoban.com/news/detail-637491.html
- mountPath: /var/run/docker.sock
name: dockersock
- mountPath: /usr/bin/docker
name: docker
- hostPath:
path: /usr/bin/docker
type: ""
name: docker
- name: jenkins-admin-token-nqbkc
secret:
defaultMode: 420
secretName: jenkins-admin-token-nqbkc
如果还不行,在jenkins插件管理中安装docker相关插件文章来源地址https://www.toymoban.com/news/detail-637491.html
到了这里,关于k8s上部署jenkins 执行pipeline docker时出现script.sh: 1: docker: not found的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!