简体   繁体   English

Jenkins Pipeline 推送 Docker 镜像

[英]Jenkins Pipeline push the Docker Image

I'm trying to push my docker image after building source code, when jenkins push images to docker Hub Registry i am getting below error.我试图在构建源代码后推送我的 docker 镜像,当 jenkins 将镜像推送到 docker Hub Registry 时,我遇到了以下错误。

Pipeline Script流水线脚本

stage('Build Docker Image') {
        container('docker') {
            echo 'docker'
            sh "docker build -t ${image_name} ."
            sh "docker tag ${image_name} ${image_name}:${image_tag}"          
        }
      } 

    stage('Push Docker Image') {
        container('docker') {
        withCredentials([string(credentialsId: 'DOCKER_HUB_CREDENTIALS', variable: 'DOCKER_HUB_CREDENTIALS')]) {
        sh "docker login -u user-name -p ${DOCKER_HUB_CREDENTIALS}"
          }
          sh "docker push ${image_name}:${image_tag}"
       }
    }

Jenkins Logs詹金斯日志

[Pipeline] // container
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Push Docker Image)
[Pipeline] container
[Pipeline] {
[Pipeline] withCredentials
Masking supported pattern matches of $DOCKER_HUB_CREDENTIALS
[Pipeline] {
[Pipeline] sh
+ docker login -u user-name -p ****
Login Succeeded
[Pipeline] }
[Pipeline] // withCredentials
[Pipeline] sh
+ docker push devopsimage.azure/frontend:bug-fix-2cbb925d
The push refers to repository [devopsimage.azure/frontend]
Get https://devopsimage.azure/v2/: dial tcp: lookup devopsimage.azure.io: Temporary failure in name resolution
[Pipeline] }
[Pipeline] // container
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // podTemplate
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE

Can you please any one help me on this ?你能请任何人帮助我吗?

If you have dot(.) in your image name before the slash, docker treats it as the registry name.如果您的镜像名称中有 dot(.) 在斜杠之前,docker 会将其视为注册表名称。 So docker push is trying to push to registry named devopsimage.azure .所以devopsimage.azure push 试图推送到名为devopsimage.azure注册表。 If you actually want to push to Docker Hub instead, remove the dot from the image name.如果您确实想推送到 Docker Hub,请从映像名称中删除点。 If you want to push to registry named devopsimage.azure , then there is a DNS issue in resolving this registry from your build machine.如果您想推送到名为devopsimage.azure注册表,则在从构建机器解析此注册表时存在 DNS 问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Jenkins Pipeline推Docker图像 - Jenkins Pipeline push Docker image Jenkins 声明式管道 - 将 Docker 映像推送到私有 docker hub 存储库 - Jenkins declarative pipeline - push Docker image to private docker hub repo Jenkins Golang 声明式管道:构建 Docker 镜像并推送到 Docker Hub - Jenkins Golang Declarative Pipeline: Build Docker Image and Push to Docker Hub Docker 图像无法通过 Jenkins 管道和 docker.withRegistry 推送到 ECR - Docker Image can't push to ECR via Jenkins Pipeline & docker.withRegistry 登录并将 docker 映像推送到运行在 k8s 上的 jenkins 管道的(不安全的)工件 docker 存储库 - Login and Push docker image to (insecure) artifactory docker repo from jenkins pipeline running on k8s 在Jenkins(在docker容器中)管道中构建docker镜像 - Build docker image in Jenkins (in docker container) pipeline 使用 Jenkins 管道 docker 插件,如何拉取图像并将新标签推送给它? - Using the Jenkins pipeline docker plugin, how to pull an image and push a new tag to it? 无法使用 Jenkins 将 docker 图像推送到 docker 集线器 - Fail to push docker image to docker hub with Jenkins 如何在 Jenkins 管道中获取 Docker 图像对象? - How to get a Docker image object in a Jenkins pipeline? 如何使用詹金斯管道参数标记Docker镜像? - How to tag docker image with jenkins pipeline parameter?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM