[英]Error when transferring Docker Image to Docker Hub using Jenkins Pipeline
Below is a portion of a Jenkins Pipeline Script that I am using to build a Docker Image and Deploy it to the Docker Hub. 以下是我用来构建Docker映像并将其部署到Docker Hub的Jenkins Pipeline脚本的一部分。 The problem that I am having is that after executing the Pipeline, the Docker Image is not transferred to Docker Hub ~and~ the local Docker Image (created during the process) is not erased.
我遇到的问题是,在执行管道之后,Docker映像不会传输到Docker Hub,并且本地Docker映像(在此过程中创建)也不会被擦除。
pipeline {
environment {
registry = "<my_docker_hub userid>/object"
registryCredential = 'dockerhub'
}
agent { label 'ubuntu16.04-slave-two' }
stages {
stage('Cloning Git') {
steps {
...
}
}
stage('Building image') {
steps{
sh "/usr/local/bin/docker-compose -p $registry:$BUILD_NUMBER build "
}
}
stage('Deploy Image') {
steps{
sh "docker push $registry:$BUILD_NUMBER"
}
}
stage('Remove Unused docker image') {
steps{
sh "docker rmi $registry:$BUILD_NUMBER"
}
}
}
}
Even though I get a SUCCESS message when building the image : 即使在构建图像时收到成功消息 :
Successfully built fe86784636c2
Successfully tagged <docker_hub_id>object44_website:latest
The image is not transferred over to the Docker Hub. 映像不会转移到Docker Hub。
Below is the log I got when running the Pipeline code: 下面是运行管道代码时得到的日志:
Started by user Jenkins Admin
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on ubuntu16.04-slave-two in /var/jenkins/workspace/oracle-client-with-flask
[Pipeline] {
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Cloning Git)
[... snip ...']
Building authorize-service
Step 1/11 : FROM oraclelinux:7
---> a803b2474b20
[... snip ...]
Step 3/4 : COPY . /var/www/html/
---> Using cache
---> e0b4cd5713c0
Step 4/4 : EXPOSE 80
---> Using cache
---> fe86784636c2
Successfully built fe86784636c2
Successfully tagged <docker_hub_id>object44_website:latest
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Deploy Image)
[Pipeline] sh
+ docker push <docker_hub_id>/object:44
The push refers to a repository [docker.io/<docker_hub_id>/object]
An image does not exist locally with the tag: <docker_hub_id>/object
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Remove Unused docker image)
Stage "Remove Unused docker image" skipped due to earlier failure(s)
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE
How can I get the Image successfully to the Docker Hub? 如何将映像成功发送到Docker Hub?
TIA TIA
EDIT: Here is the docker-compose.yml file 编辑:这是docker-compose.yml文件
version: '3'
services:
authorize-service:
build: ./authorizations
container_name: authorize-service
environment:
- DB_IP=XXX.XX.XX.XX
- DB_PORT=1521
- DB_SID=TEST
- DB_USER=xxxxxxx
- DB_PASS=xxxxxxx
ports:
- 2700:5000
networks:
- kdcnetwork
testtab-service:
build: ./testtab
container_name: testtab-service
environment:
- DB_IP=XXX.XX.XX.XX
- DB_PORT=1521
- DB_SID=TEST
- DB_USER=xxxxx
- DB_PASS=xxxxx
ports:
- 2800:5000
networks:
- kdcnetwork
website:
build: ./website
container_name: testtab-website
links:
- testtab-service
volumes:
- ./website:/var/www/html
ports:
- 5000:80
networks:
- kdcnetwork
depends_on:
- testtab-service
networks:
kdcnetwork:
driver: bridge
You didn't provide docker-compose file so I cannot give very accurate answer but I can simply find that 您没有提供docker-compose文件,所以我无法给出非常准确的答案,但我可以简单地找到
Successfully tagged <docker_hub_id>object44_website:latest
differs from what you are trying to push: 与您要推送的内容不同:
docker push <docker_hub_id>/object:44
those 2 names must be the same. 这两个名称必须相同。
Edit: 编辑:
So you must change section in your docker-compose to following 因此,您必须将docker-compose中的部分更改为以下内容
website:
build: ./website
image: <docker_hub_id>/object:44
so docker-compose will build image <docker_hub_id>/object:44
and your docker push command should be able to push it 因此,
<docker_hub_id>/object:44
-compose将构建映像<docker_hub_id>/object:44
并且您的<docker_hub_id>/object:44
push命令应该能够对其进行推送
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.