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.
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. So docker push is trying to push to registry named devopsimage.azure
. If you actually want to push to Docker Hub instead, remove the dot from the image name. If you want to push to registry named devopsimage.azure
, then there is a DNS issue in resolving this registry from your build machine.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.