maven docker push harbor

maven docker push harbor
docker-maven-plugin

一.在m2 setting.xml的servers节点增加一个server节点


        
      docker-harbor
      your username
      your passwd
      
            your email
      
    

二.在环境变量增加
DOCKER_HOST:tcp://172.16.9.6:2375
如果本机没有docker daemon环境,找一台已经部署了docker并打开api remote接口设置。
参考 https://www.cnblogs.com/520playboy/p/7921633.html

三.在你的maven项目新建 src/main/docker/Dockerfile 如图
maven docker push harbor_第1张图片
FROM tomcat:8
COPY crms.war /usr/local/tomcat/webapps/app.war
CMD [“catalina.sh”, “run”]

四:在pom.xml的properties节点增加
chezhibao
harbor.mychebao.com
cicd

五:在pom.xml的build节点增加

 
        crms
        
            
            
                org.apache.maven.plugins
                maven-war-plugin
                
                    ${project.artifactId}
                    
                    
                    
                        
                            src/main/webapp
                            true
                            
                                **/*.xml
                            
                        
                    
                
            
              
                    com.spotify
                    docker-maven-plugin
                    0.4.13
                    
                        
                            package
                            
                                build
                            
                        
                        
                            tag-image
                            package
                            
                                tag
                            
                            
                                ${docker.repostory}/${docker.registry.name}/${project.artifactId}:${project.version}
                                ${docker.repostory}/${docker.registry.name}/${project.artifactId}:${project.version}
                            
                        
                        
                            push-image
                            deploy
                            
                                push
                            
                            
                                ${docker.repostory}/${docker.registry.name}/${project.artifactId}:${project.version}
                            
                        
                    
                    
                        docker-harbor
                        ${docker.repostory}
                        true
                        true
                        src/main/docker
                        
                            ${docker.repostory}/${docker.registry.name}/${project.artifactId}:${project.version}
                        
                        
                            ${project.version}
                        
                        
                            
                                
                                target/
                                ${project.build.finalName}.war
                            
                        
                    
                
            
    

六.看一下结果
maven docker push harbor_第2张图片

maven docker push harbor_第3张图片

七.docker pull harbor.****.com/cicd/crms:CRED-499-SNAPSHOT

你可能感兴趣的:(docker)