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.
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.