创建自定义maven的docker镜像

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

有时docker的官方maven镜像不能满足我们需求时,我们需要自定义maven的settings.xml文件,加上阿里云的映射和自己的私服

  1. clone阿里云maven-image仓库:[email protected]:AliyunContainerService/maven-image.git

  2. 进入3-jdk-8目录,修改settings.xml文件


  /usr/share/maven/ref/repository
  
     
      youseniu-releases 
      xxx 
      xxxx 
    
    
      youseniu-snapshots 
      xxxx 
      xxxxx 
    
  
  
    
      alimaven
      aliyun maven
      https://maven.aliyun.com/repository/central
      central        
    
  
  

    
      youseniu 
       
         
          youseniu 
          youseniu private nexus 
          http://ysnnexus.liyuchang.xin/repository/maven-public/
          
            true
           
          
            true
           
        
       
       
         
          youseniu 
          youseniu private nexus 
          http://ysnnexus.liyuchang.xin/repository/maven-public/
          
            true
           
          
            true
           
         
       
    
      
      jdk-1.8  
        
        true  
        1.8  
        
        
        1.8  
        1.8  
        1.8  
        
    
  
  
    youseniu
  

  1. build镜像
#build
docker build --tag liyc/maven:3.5.2-jdk-8 .
#push
docker push liyc/maven:3.5.2-jdk-8
#pull
docker pull liyc/maven:3.5.2-jdk-8
  1. 使用新镜像运行maven项目
#进入项目所在目录
cd /maven_project_home
#运行
docker run --name testproject 
    -it --rm -p 8080:8080  
    -v "$(pwd)":/usr/src/mymaven -v maven-repo:/usr/share/maven/ref/repository 
    -w /usr/src/mymaven --restart=on-failure liyc/maven:3.5.4-jdk-8 
    mvn spring-boot:run -Duser.timezone=Asia/Shanghai

maven官方docker
阿里maven-image

转载于:https://my.oschina.net/u/3656540/blog/1934351

你可能感兴趣的:(创建自定义maven的docker镜像)