Docker

如何在 RHEL 基礎映像上的 Jenkins 中執行 docker 代理?

  • January 2, 2020

我讓 Jenkins 在 RHEL 8 上執行。我正在嘗試執行我的管道,但它不起作用,我認為這可能是 Podman 的問題,因為我能夠在使用 docker-ce 的機器上執行管道。

我已經在 /etc/subuid 文件上配置了 jenkins 使用者並重新啟動。現在我收到另一個與 docker 相關的錯誤。

這是日誌:

Checking out Revision 113a2a700837d2de2ed99eabec4ff994b1392a6a (origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f 113a2a700837d2de2ed99eabec4ff994b1392a6a # timeout=10
Commit message: "Jenkins"
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] isUnix
[Pipeline] sh

+ docker inspect -f . node:12
.
[Pipeline] withDockerContainer
ERROR: Failed to parse docker version. Please note there is a minimum docker version requirement of v1.7.
Jenkins does not seem to be running inside a container
$ docker run -t -d -u 993:990 -p 3000:3000 -w /var/lib/jenkins/workspace/blade-runner-pipeline -v /var/lib/jenkins/workspace/blade-runner-pipeline:/var/lib/jenkins/workspace/blade-runner-pipeline:rw,z -v /var/lib/jenkins/workspace/blade-runner-pipeline@tmp:/var/lib/jenkins/workspace/blade-runner-pipeline@tmp:rw,z -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** node:12 cat
$ docker top c35bc763bb7bfedffa2a3629ee8e48132d9175df6e43fea207262c13c1372f3f -eo pid,comm

[Pipeline] // withDockerContainer
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
java.io.IOException: Cannot retrieve .Image from 'docker inspect c35bc763bb7bfedffa2a3629ee8e48132d9175df6e43fea207262c13c1372f3f'
   at org.jenkinsci.plugins.docker.workflow.client.DockerClient.inspectRequiredField(DockerClient.java:225)
   at org.jenkinsci.plugins.docker.workflow.client.DockerClient.getContainerRecord(DockerClient.java:352)
   at org.jenkinsci.plugins.docker.workflow.WithContainerStep$Execution.start(WithContainerStep.java:209)
   at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:286)
   at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:179)
   at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122)
   at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:48)
   at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
   at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)

和我的 Jenkinsfile

pipeline {
     agent {
       docker {
         image 'node:12' 
           args '-p 3000:3000' 
       }
     }
     stages {
       stage('Build') { 
         steps {
           sh 'yarn install' 
           sh 'yarn test'
           sh 'echo " ==== PASSED ===="'
         }
       }
     }
   }

這可能是與 podman 相關的錯誤,由https://github.com/containers/libpod/issues/4193引起。

不太確定,哪個 podman 版本正在解決這個問題,我猜它 >= 1.6.1。podman inspect -f "{{.Image}}" c35bc763bb7bfedffa2a3629ee8e48132d9175df6e43fea207262c13c1372f3f 您可以通過在 RHEL 機器上執行來驗證這一點以及可能的修復 。

引用自:https://serverfault.com/questions/996885