Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在本地计算机上查找docker映像_Docker_Jenkins Plugins_Dockerfile_Jenkins Pipeline_Docker Machine - Fatal编程技术网

如何在本地计算机上查找docker映像

如何在本地计算机上查找docker映像,docker,jenkins-plugins,dockerfile,jenkins-pipeline,docker-machine,Docker,Jenkins Plugins,Dockerfile,Jenkins Pipeline,Docker Machine,我在本地机器上有一个docker映像。当我尝试使用下面的Jenkins文件运行图像时 agent { docker { image 'gcc/sample:latest' args "-v /etc/passwd:/etc/passwd:ro } } 然后我得到以下错误 + docker pull gcc/sample:latest Pulling repository docker.io/gcc/sample Error: image gcc/sample:la

我在本地机器上有一个docker映像。当我尝试使用下面的Jenkins文件运行图像时

agent {
docker {
image 'gcc/sample:latest'
args "-v /etc/passwd:/etc/passwd:ro 
        }
    }
然后我得到以下错误

+ docker pull gcc/sample:latest

Pulling repository docker.io/gcc/sample

Error: image gcc/sample:latest not found

script returned exit code 1

我可以在Jenkins文件中说,在本地机器上查找docker映像,而不是docker.io查找docker映像

结果表明,这已经是一个已知的问题:


docker映像始终拉入代理定义中。同时,唯一的解决方案是将映像推送到Dockerhub或私有注册表,以便成功地将其提取。

为此,您需要在本地计算机或Jenkins运行的Jenkins服务器上安装docker注册表。 只需运行docker注册表容器

 docker run -d -p 5000:5000 --restart always --name registry registry:2
首先标记您的图像

docker tag alpine localhost:5000/gcc/sample:latest
将该图像推送到本地docker注册表

docker push localhost:5000/gcc/sample:latest
现在,如果你想在jenkins中拉取docker图像,那么在我们从docker注册表中拉取一些东西时,请给出带dns的拉取路径,因为它包含带dns的全名

docker pull localhost:5000/gcc/sample:latest
注册表是一个存储和内容交付系统,包含命名的Docker图像,有不同的标记版本。

docker pull ubuntu指示docker从官方docker Hub中提取一个名为ubuntu的图像。这只是较长docker pull docker.io/library/ubuntu命令的快捷方式

docker pull myregistrydomain:port/foo/bar指示docker联系 位于myregistrydomain:端口的注册表用于查找映像 foo/bar

运行您自己的注册表是与和集成的一个很好的解决方案 补充您的CI/CD系统


在我们的环境中,由于某些原因,使用并行阶段可以防止拉操作

#!/usr/bin/env groovy
pipeline {
    agent none

    options {
        timestamps()
    }

    stages {
        stage('Parallel') {
            parallel {
                stage('EL6') {
                    agent { 
                        docker { 
                            image 'centos6'
                            label 'Docker&&EL'
                        }
                    }
                    steps {
                        ...
                    }
                }
            }
        }
    }
}
背景:我们通常使用具有并行步骤的多分支管道作业。在测试一些新的东西时,我编写了一个利用docker的最简单的Jenkins文件。我使用了一个没有平行部分的简单管道作业,并注意到它总是尝试拉(并失败)

相关插件:

Docker Commons Plugin
Provides the common shared functionality for various Docker-related plugins.
1.11
Downgrade to 1.11

Docker Pipeline
Build and use Docker containers from pipelines.
1.15

Pipeline: API
Plugin that defines Pipeline API.
2.28
Downgrade to 2.25

Pipeline: Basic Steps
Commonly used steps for Pipelines.
2.6

Pipeline: Declarative
An opinionated, declarative Pipeline.
1.2.7

Pipeline: Declarative Agent API
Replaced by Pipeline: Declarative Extension Points API plugin.
1.1.1

Pipeline: Declarative Extension Points API
APIs for extension points used in Declarative Pipelines.
1.2.7

Pipeline: Job
Defines a new job type for pipelines and provides their generic user interface.
2.17

Pipeline: Model API
Model API for Declarative Pipeline.
1.2.7


Pipeline: Stage Step
Adds the Pipeline step stage to delineate portions of a build.
2.3

Pipeline: Stage Tags Metadata
Library plugin for Pipeline stage tag metadata.
1.2.7

Pipeline: Stage View Plugin
Pipeline Stage View Plugin.
2.9

Pipeline: Step API
API for asynchronous build step primitive.
2.16
Downgrade to 2.14

Pipeline: Supporting APIs
Common utility implementations to build Pipeline Plugin
2.17


jenkins是在docker容器中运行还是直接在机器上运行?jenkins是直接在Linux机器上运行。是否在本地找到映像
gcc/sample:latest
?当您使用标签latest运行
docker image ls
时是否会显示该图像?该图像在本地显示,但当我使用上述Jenkins文件(图像“gcc/sample:latest”)时,它不会在本地显示。它只是在回购。