0

my docker file:

FROM tomcat

MAINTAINER "Shan Khan <xxx@gmail.com">

RUN ["rm", "-rf", "/usr/local/tomcat/webapps/ROOT"]

COPY ROOT.war /usr/local/tomcat/webapps/

CMD ["/usr/local/tomcat/bin/catalina.sh", "run"]

running as:

sudo docker build -t webserver
sudo docker run -it --rm -p 8080:8080 webserver

tomcat is running but im unable to access in the localhost:8080 or localhost:8080/ROOT

Shan Khan
  • 9,667
  • 17
  • 61
  • 111

2 Answers2

0

When I was doing this for a work project I seem to remember having to deploy the app to the Tomcat root.

Deploying my application at the root in Tomcat

So basically you would need to add some steps to your Dockerfile to accomplish this.

Community
  • 1
  • 1
david_i_smith
  • 228
  • 3
  • 12
  • i have tried to add it and put inside the ROOT folder, updated the docker file, but localhost displays now empty page rather than this war file. – Shan Khan Dec 21 '16 at 11:49
  • The accepted answer here also rings a bell: http://stackoverflow.com/questions/7276989/howto-set-the-context-path-of-a-web-application-in-tomcat-7-0. Sorry, it's been a while since I had to do this. – david_i_smith Dec 21 '16 at 14:21
  • i have tried it actually, changed the question, and removed the root folder and than running it, same problem – Shan Khan Dec 27 '16 at 09:29
0

instead of using CMD ["/usr/local/tomcat/bin/catalina.sh", "run"], try to do it as ENTRYPOINT ["/usr/local/tomcat/bin/catalina.sh", "run"]

If this do not resolve your problem, try to see the logs. In the logs you will see something like deploying webapp ROOT. If you do not see this logs but you get server startup took ***ms, then try to check war file locally or see if there are some errors popping up in catalina.out file inside logs folder by connecting to the docker container. (docker ps- command to check the docker container running your dockerfile)

Ani
  • 463
  • 4
  • 20