docker基于ubuntu镜像自动化部署war

环境

docker:Docker version 17.11.0-ce
ubuntu: 14.04
java: 8
tomcat: 7

docker化,并上传至harbor

  1. Dockerfile

     FROM ubuntu:14.04
    
     MAINTAINER    xiaojie
     
     ADD jdk-8u71-linux-x64.tar.gz /usr/local/
     
     ADD apache-tomcat-7.0.70.tar.gz  /usr/local/
     
     ADD  tomcat-users.xml /usr/local/apache-tomcat-7.0.70/conf/
     
     ADD  settings.xml /usr/local/apache-tomcat-7.0.70/conf/
     
     ADD  demo.war /usr/local/apache-tomcat-7.0.70/webapps/
     
     ENV JAVA_HOME /usr/local/jdk1.8.0_71
     
     ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
     
     ENV CATALINA_HOME /usr/local/apache-tomcat-7.0.70
     
     ENV CATALINA_BASE /usr/local/apache-tomcat-7.0.70
     
     ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/lib:$CATALINA_HOME/bin
     
     EXPOSE 8080
     
     ENTRYPOINT ["/usr/local/apache-tomcat-7.0.70/bin/catalina.sh", "run" ]
    
  2. tomcat-users.xml



  
    
     
        
     
  1. settings.xml
    


    
        TomcatServer
        demo
         demo11111
    


  1. build, run

     docker stop demo-container
     docker rm demo-container
     docker build -t demo/tomcat .
     docker run --name demo-container -d -p 8080:8080 demo/tomcat  
    
  2. push之前需要将harbor地址加入到信任中,vi /etc/default/docker

    DOCKER_OPTS="$DOCKER_OPTS --insecure-registry ...:8888"

  3. push至私有harbor库

     docker login -u demo -p password123   **.**.**.**:8888
     docker tag demo/tomcat **.**.**.**:8888/demo/tomcat
     docker push **.**.**.**:8888/demo/tomcat
    

坑点

  1. 保持tomcat版本、java版本和开发环境一样,不然可能会有莫名的问题

你可能感兴趣的:(docker基于ubuntu镜像自动化部署war)