Aaron Guilbot
Aaron Guilbot

Reputation: 199

Docker image run but nothing on my Chrome

I run a docker on my machine

enter image description here

When i want to acces to my docker http://127.0.0.1:8888 i have error enter image description here

Why it's wrong ?

Dockerfile:

FROM tomcat:9-jre8
RUN echo "export JAVA_OPTS=\"-Dapp.env=staging\"" > /usr/local/tomcat/bin/setenv.sh  
# Copy to images tomcat path
ADD /target/*.war /usr/local/tomcat/webapps/myProject.war
EXPOSE 8888
CMD ["catalina.sh", "run"]

Upvotes: 7

Views: 1553

Answers (2)

Tapan Hegde
Tapan Hegde

Reputation: 1328

I just tried to run tomcat-9 in docker with 8080 port and was able to do that.

  1. I cloned some sample git-hub link, which has sample hello-world program.

git clone https://github.com/efsavage/hello-world-war

  1. Created docker file with entries given above. Just Exposed port as 8080 (Tomcat default port)
FROM tomcat:9-jre8
RUN echo "export JAVA_OPTS=\"-Dapp.env=staging\"" > /usr/local/tomcat/bin/setenv.sh
ADD /target/*.war /usr/local/tomcat/webapps/myProject.war
EXPOSE 8080
CMD ["catalina.sh", "run"]

  1. Built docker image.
docker build -t tomcat_image .
  1. Run docker image
docker run -p 8080:8080 tomcat_image:latest
  1. Access "http://127.0.0.1:8080/" in web browser, I used google chrome. Voila!! It worked. Please find below screenshot

enter image description here

Hope this helps!!

Update : Tried with 8888 port, It worked!!. As suggested by @Mohit Mutha , you need to run docker run command by mapping the port with 8080.

docker run -p 8888:8080 tomcat_image:latest

Attached new screenshot. enter image description here

Upvotes: 0

Mohit Mutha
Mohit Mutha

Reputation: 3001

Tomcat runs http on the port 8080 by default. You should change your mapping to port 8080

for eg. docker run -p 8080:8080 <your image name>

If you want tomcat to run on a port other than 8080 you will need to edit the server.xml and change the port. I will not recommend to do that in the docker container. Rather keep tomcat running on default port and change the port mapping. So if you want the service to be exposed on port 8888 on the local machine then change the mapping to

docker run --publish=8888:8080 -d registry.gitlab.com/myproject/registry:develop

Upvotes: 6

Related Questions