我在kubernetes(AWS EKS)上部署了Jenkins,并为Jenkins管道任务指定了一个节点。我有一个管道,我想构建一个Docker映像,下面是我的管道的外观:
pipeline {
agent {
kubernetes {
defaultContainer 'jnlp'
yaml """
apiVersion: v1
kind: Pod
spec:
nodeSelector:
illumex.ai/noderole: jenkins-worker
containers:
- name: docker
image: docker:latest
imagePullPolicy: Always
command:
- cat
tty: true
volumeMounts:
- mountPath: /var/run/docker.sock
name: docker-sock
volumes:
- name: docker-sock
hostPath:
path: /var/run/docker.sock
"""
}
}
stages {
stage('build') {
steps {
container('system') {
sh """
docker system prune -f
"""
但是,我的工作失败的原因是:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
我认为这是权限问题。然而,由于容器是作为管道的一部分创建的,那么我应该给予哪个用户权限呢?
1条答案
按热度按时间jecbmhm31#
在Jenkins计算机上,确保安装了docker,并且用户jenkins位于docker组中。
安装Docker插件是不够的,必须在Jenkins机器上安装Kubectl插件。