docker - Jenkins管道中的Openshift Docker CLI

标签 docker jenkins jenkins-pipeline openshift

我正在尝试使用Openshift 3.9中的管道构建,我需要使用docker CLI。我不知道如何在管道中使用“docker”命令。

我已经在声明性管道中尝试了以下代码,但收到“docker:not found”

pipeline {
            agent {
                docker { image 'node:7-alpine' }
            }
            stages {
                stage('Test') {
                    steps {
                        sh 'node --version'
                    }
                }
            }
          }

代码是从这里复制的:

https://jenkins.io/doc/book/pipeline/docker/

我还尝试了它的脚本版本:
node {
    /* Requires the Docker Pipeline plugin to be installed */
    docker.image('node:7-alpine').inside {
        stage('Test') {
            sh 'node --version'
        }
    }
}

但是得到了同样的错误:“docker:找不到命令”

Docker管道插件已安装(版本:1.17)
Openshift版本:3.9

有什么建议么?谢谢!

最佳答案

似乎您在运行管道的节点上没有安装docker。您需要先安装它。如果没有预先配置,就无法在安装Docker Plugin之后立即使用docker命令:

By default, the Docker Pipeline plugin will communicate with a local Docker daemon, typically accessed through /var/run/docker.sock.

关于docker - Jenkins管道中的Openshift Docker CLI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54206250/

相关文章:

amazon-web-services - 如何在此 Jenkinsfile 步骤中获取 AWS AccountID

macos - docker容器更改不保存,osx

docker - Neo4j Docker内存不足

docker推送到注册表不起作用

amazon-web-services - AWS更新后重新部署Docker

grails - 在 Jenkins 中更轻松地获得测试结果

node.js - 在使用 Docker 的 Jenkins Pipeline 的构建后操作中似乎无法触发 "failure"事件

jenkins - 设置Jenkins工作流(管道)构建的内部版本号

Powershell 和 Jenkins - 以另一个用户身份执行 Powershell 脚本

jenkins - 如何使用groovy在jenkins中获取当前构建的节点名称