Reputation: 445
I don't know how to deploying the war file into tomcat 7 with the help of docker container.
It is easy in windows OS because we manually paste our project's war file into webapps
folder of tomcat, but in case of docker container it is little bit difficult.
I don't know how to change port of tomcat and add role manager in tomcat-users.xml
file in docker because of directory structure of docker container. and how to start tomcat using newly change port number in docker.
Upvotes: 0
Views: 7271
Reputation: 109
As for March 2021, using a single command line solution on a Windows Docker, try this:
docker run --name YourApp -v "c/WarFiles/YourApp.war:/usr/local/tomcat/webapps/YourApp.war" -it -p 9090:8080 tomcat:7
Then open your app at http://localhost:9090/YourApp
Note "double quote" in volume and c drive with "Linux" slash / in order to make it work.
Upvotes: 0
Reputation: 4809
The easiest way is to use the volume parameter (-v
) with docker run
to have the webapps
directory and tomcat-users.xml
file stay on the host filesystem, not on the container one.
For instance, on a Linux host:
/tmp/tomcat-users.xml
with the correct content for your needs;/tmp/webapps
.Now, run your container this way:
docker run -it --rm -p 8888:8080 -v /tmp/tomcat-users.xml:/usr/local/tomcat/conf/tomcat-users.xml:ro -v /tmp/webapps:/usr/local/tomcat/webapps:rw tomcat:7
Then, since the container is started in foreground, connect to another shell (another window) and copy your war file into /tmp/webapps. It will be automatically deployed.
For instance, on a Windows host:
c:\tmp\tomcat-users.xml
with the correct content for your needs;c:\tmp\webapps
.Now, run your container this way:
docker run -it --rm -p 8888:8080 -v //c/tmp/tomcat-users.xml:/usr/local/tomcat/conf/tomcat-users.xml:ro -v //c/tmp/webapps:/usr/local/tomcat/webapps:rw tomcat:7
Then copy your war file into c:\tmp\webapps
. It will be automatically deployed.
Upvotes: 4