Jenkins管道无法提取Docker图像

5lhxktic  于 2022-11-21  发布在  Jenkins
关注(0)|答案(1)|浏览(242)

我目前面临的情况是,在Jenkins管道期间无法提取Docker图像。Jenkins正在Jenkins Documentation中建议的容器中运行
每当我运行管道时,都会遇到以下错误:

Started by user piii
Replayed #32
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/jenkins_home/workspace/lms-portal
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
Selected Git installation does not exist. Using Default
The recommended git tool is: NONE
using credential 9d587d39-cf26-4eba-b08e-d9732a70a5b9
 > git rev-parse --resolve-git-dir /var/jenkins_home/workspace/lms-portal/.git # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://github.com/Piii-thagorus/lms_portal.git # timeout=10
Fetching upstream changes from https://github.com/Piii-thagorus/lms_portal.git
 > git --version # timeout=10
 > git --version # 'git version 2.30.2'
using GIT_SSH to set credentials jenksins_ssh
[INFO] SELinux is present on the host and we could not confirm that it does not apply actively: will try to relabel temporary files now; this may complain if context labeling not applicable after all
 > /usr/bin/chcon --type=ssh_home_t /var/jenkins_home/workspace/lms-portal@tmp/jenkins-gitclient-ssh9208860798294607535.key
Verifying host key using known hosts file
You're using 'Known hosts file' strategy to verify ssh host keys, but your known_hosts file does not exist, please go to 'Manage Jenkins' -> 'Configure Global Security' -> 'Git Host Key Verification Configuration' and configure host key verification.
 > git fetch --tags --force --progress -- https://github.com/Piii-thagorus/lms_portal.git +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git rev-parse refs/remotes/origin/testing^{commit} # timeout=10
Checking out Revision 3e0e59d57c873b5869628455c28fc82d66f1570f (refs/remotes/origin/testing)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 3e0e59d57c873b5869628455c28fc82d66f1570f # timeout=10
Commit message: "Removed docker as agent"
 > git rev-list --no-walk 3e0e59d57c873b5869628455c28fc82d66f1570f # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] isUnix
[Pipeline] withEnv
[Pipeline] {
[Pipeline] sh
+ docker inspect -f . node:latest

error during connect: Get "https://docker:2376/v1.24/containers/node:latest/json": dial tcp: lookup docker: no such host
[Pipeline] isUnix
[Pipeline] withEnv
[Pipeline] {
[Pipeline] sh
+ docker pull node:latest
error during connect: Post "https://docker:2376/v1.24/images/create?fromImage=node&tag=latest": dial tcp: lookup docker: no such host
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE

下面是我的管道,那里

pipeline {

    agent {
        docker { image 'node:latest' }
    }

    stages {

        stage('Prepare'){
        
            steps{
                    sh 'echo "starting"'
            }
        }   
    }   
}

这是什么原因?任何解决方案都是值得赞赏的。
谢谢你

ttygqcqt

ttygqcqt1#

据我所知,您正在将Jenkins作为容器运行,并且您希望运行一个构建,在该构建中您需要拉入一个Docker容器。
如果我是对的,让我把话说清楚。
您将Jenkins作为Docker容器运行,这意味着您在运行Docker的地方没有Jenkins的本地安装。Jenkins容器也不运行Docker,因此您尝试从没有Docker的地方提取Docker容器。
有一个解决方案。你可以安装docker插件并配置它。找到插件文档here
另外,你也可以尝试使用this。在第二个超链接中有一个部分展示了如何在使用Docker代理之前对其进行配置。
希望这对你有帮助,祝你有美好的一天。

相关问题