1

我正在使用Jkube maven 插件通过 Jenkins 管道在 Ubuntu 下的 AWS EC2 实例上生成 Docker 映像。
当管道执行时mvn clean install k8s:build,我收到此错误:

[ERROR] Failed to execute goal org.eclipse.jkube:kubernetes-maven-plugin:1.3.0:build (default-cli) on project social-carpooling-frontend: Execution default-cli of goal org.eclipse.jkube:kubernetes-maven-plugin:1.3.0:build failed: No <dockerHost> given, no DOCKER_HOST environment variable, no read/writable '/var/run/docker.sock' or '//./pipe/docker_engine' and no external provider like Docker machine configured -> [Help 1]

这是 Jenkins 管道:

pipeline {
  agent any
  stages {
    stage('Docker Check Stage') {
      steps {
        sh '/home/bitnami/downloads/apache-maven-3.8.1/bin/mvn clean install k8s:build -Premote'
      }
    }
  }
}

当我使用 ssh 登录到这台机器并执行docker -v它时说Docker version 20.10.0, build 7287ab3

所以 Docker 真的安装了,守护进程也启动了,但是当我通过 maven 触发它时,似乎找不到它!有任何想法吗 ?

4

1 回答 1

1

问题是由于运行 maven 命令的用户无权访问docker.sock

解决方案是通过这种方式修改 docker.sock 的读/写权限:

sudo chmod 776 /var/run/docker.sock
于 2021-06-26T23:37:25.237 回答