Deploying Java webapp to Tomcat 8 running in Docker container

前端 未结 3 832
青春惊慌失措
青春惊慌失措 2020-12-13 05:48

I am pretty new to Tomcat and Docker - so I am probably missing a Tomcat fundamental somewhere in this question.

What I am trying to do is build a Docker container t

相关标签:
3条回答
  • 2020-12-13 06:18

    Tomcat will only extract the war which is copied to webapps directory. Change Dockerfile as below:

    FROM tomcat:8.0.20-jre8
    COPY /1.0-SNAPSHOT/my-app-1.0-SNAPSHOT.war /usr/local/tomcat/webapps/myapp.war
    

    You might need to access the url as below unless you have specified the webroot

    http://192.168.59.103:8888/myapp/getData

    0 讨论(0)
  • 2020-12-13 06:28

    There's a oneliner for this one.

    You can simply run,

    docker run -v /1.0-SNAPSHOT/my-app-1.0-SNAPSHOT.war:/usr/local/tomcat/webapps/myapp.war -it -p 8080:8080 tomcat
    

    This will copy the war file to webapps directory and get your app running in no time.

    0 讨论(0)
  • 2020-12-13 06:35

    You are trying to copy the war file to a directory below webapps. The war file should be copied into the webapps directory.

    Remove the mkdir command, and copy the war file like this:

    COPY /1.0-SNAPSHOT/my-app-1.0-SNAPSHOT.war /usr/local/tomcat/webapps/myapp.war
    

    Tomcat will extract the war if autodeploy is turned on.

    0 讨论(0)
提交回复
热议问题