Reputation: 199
I run a docker on my machine
When i want to acces to my docker http://127.0.0.1:8888
i have error
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
Reputation: 1328
I just tried to run tomcat-9 in docker with 8080 port and was able to do that.
git clone https://github.com/efsavage/hello-world-war
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"]
docker build -t tomcat_image .
docker run -p 8080:8080 tomcat_image:latest
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
Upvotes: 0
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