Jenkins 构建镜像以及上传镜像

[root@jenkins-agent devops-web-service-master]# ls dist/
index.html  static

[root@jenkins-agent devops-web-service-master]# cat Dockerfile 
FROM nginx:1.17.7

COPY dist/ /usr/share/nginx/html

[root@jenkins-agent devops-web-service-master]# docker build -t npm:1 .
Sending build context to Docker daemon  184.2MB
Step 1/2 : FROM nginx:1.17.7
 ---> c7460dfcab50
Step 2/2 : COPY index.html /usr/share/nginx/html
 ---> bd119bfc6566
Successfully built bd119bfc6566
Successfully tagged npm:1

[root@jenkins-agent devops-web-service-master]# docker run -itd -p 89:80 --name npm npm:1
2810ba5f6c162218ddfe2d8424c501aa7a1fc4aacabf08b545cad8fb64ee9112

	    stage("PushImages"){
			steps {
				script {
				sh """
                    docker login 192.168.100.4:88
                    docker build -t npm:1 .
                    docker tag npm:1 192.168.100.4:88/devops/npm:1
                    docker push 192.168.100.4:88/devops/npm:1
				"""
				}
			}
		}



[Pipeline] { (PushImages)
[Pipeline] script
[Pipeline] {
[Pipeline] sh
+ docker login 192.168.100.4:88
Authenticating with existing credentials...
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
+ docker build -t npm:1 .
Sending build context to Docker daemon  156.6MB

Step 1/2 : FROM nginx:1.17.7
 ---> c7460dfcab50
Step 2/2 : COPY dist/ /usr/share/nginx/html
 ---> 9df39ec2d5e1
Successfully built 9df39ec2d5e1
Successfully tagged npm:1
+ docker tag npm:1 192.168.100.4:88/devops/npm:1
+ docker push 192.168.100.4:88/devops/npm:1
The push refers to repository [192.168.100.4:88/devops/npm]
2096de65a60b: Preparing
c26e88311e71: Preparing
17fde96446df: Preparing
556c5fb0d91b: Preparing
c26e88311e71: Pushed
2096de65a60b: Pushed
17fde96446df: Pushed
556c5fb0d91b: Pushed
1: digest: sha256:9dbc7628506d12d4dc4951073f8a7e060aa26945bfdba125b32d5392beaeaac8 size: 1158
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS


版权声明:本文为qq_34556414原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。