Correct way to deploy WAR files in docker image

后端 未结 5 1876
梦毁少年i
梦毁少年i 2020-12-13 10:19

What is the docker way to deploy java projects in a docker container?

Do I copy the war into webapps:

FROM jetty:9.2.10
MAINTAINER Me \"me@me.com\"
A         


        
5条回答
  •  渐次进展
    2020-12-13 10:39

    If you stumbled here, like I did, looking for how to simply get a WAR deployed in a container (using Apache Tomcat), and didn't care whether or not you have a Dockerfile.

    A simple, elegant solution.

    docker run \
    -d \ # Detached mode, swap for -it if we want interactive.
    -p 8080:8080  \
    -v ${absolute_path_your_project_dir}/${MY_WAR}.war:/usr/local/tomcat/webapps/app.war \
    tomcat:latest
    

    Then navigate to http://localhost:8080/app/.

    If that link doesn't work for you, be sure to change ...8080/app/ in the URL to whatever matches the .war name you gave in /usr/local/tomcat/webapps/app.war.

    I also found that, while working through IntelliJ's Docker Plugin, it's easy to adapt this to Docker Plugins. Just be sure to put in your full path.

提交回复
热议问题