0

I just started to study docker.I want to run a site on tomcat in docker.i created Dockerfile.

FROM tomcat
ADD . ./webapps
EXPOSE 1234

CMD ["catalina.sh", "run"]

Ran it and everything loaded.

Step 1/5 : FROM tomcat
---> b0e0b0a92cf9
Step 2/5 : WORKDIR usr/local/tomcat/webapps
---> Running in ab6a23f95955
Removing intermediate container ab6a23f95955
---> 08731620b120
Step 3/5 : COPY . .
---> d6fe62efeaaa
Step 4/5 : EXPOSE 1234
---> Running in 18aadc814230
Removing intermediate container 18aadc814230
---> 445c749cb133
Step 5/5 : CMD ["catalina.sh", "run"]
---> Running in a3869dab8657
Removing intermediate container a3869dab8657
---> 6654588fc0f5

Successfully built 6654588fc0f5
Successfully tagged index:2.0
Existing container found: 2b36189ed9e57f8eaeae366485c1dc27acd4773ec18233e4e7b8c695e293e310, 
removing...
Creating container...
Container Id: 3d1ee639b064a0ce0c1c38037ecc4b7f3cada03ffc6058b5fc903acb5e3cc519
Container name: 'my-container-2'
Attaching to container 'my-container-2'...
Starting container 'my-container-2'
'my-container-2 Dockerfile: Dockerfile' has been deployed successfully.

Now I want to open the site in a browser. I write url http://192.168.99.100:1234/index but i get HTTP Status 404.Why?

  • The URL looks wrong. An URL does normally not correspond directly to a filesystem path, so having `/usr/local/tomcat` (and on top of that, having it twice) in your URL is incorrect. What the URL should be depends on the configuration of Tomcat, and since you didn't show that, we can't tell you what it should be exactly. – Jesper Nov 10 '21 at 17:30
  • Does this answer your question? [.war on tomcat on docker, 404 on servlet](https://stackoverflow.com/questions/69805687/war-on-tomcat-on-docker-404-on-servlet) – Piotr P. Karwasz Nov 10 '21 at 20:36

2 Answers2

1

It's very embarrassing to admit the decision)) The fact is that when I wrote all this, I did not start the container, so of course it did not work for me.You need to start the container in the console.

0

The way you describe the error sounds strange.

Your dockerfile shows us the script how a container is built. But you did not show how you ran docker build. Especially I do not see that you reconfigured Tomcat to listen on port 1234 - which means it will still be listening on port 8080. After docker build has run, you have a container image on the disk.

Next you do not show that you created and started a container as you would via docker run. Should I assume now there is no container running, or you have a container running that tries to listen to port 8080 and we do not know on which port it would be accessible (`docker run -p 1234:8080).

Not knowing what is listening on 192.168.99.100:1234 it is hard to say why you should get a HTTP error code 404.

Try to give more information about the commands you launched and their response, and tell us what you expect so we can help better.

Finally I know some people think my response should have been a comment. Try to put that much text into comments...

Queeg
  • 7,748
  • 1
  • 16
  • 42
  • in Docker Quickstart Terminal I ordered it to open through port 1234.I also launched a container with this image.I didn't even open the start page of the tomkat.Immediately 404 error.Only then I read that it no longer opens the start page. – Денис Задорожний Nov 10 '21 at 20:55