[英]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.