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?
CodePudding user response:
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...
CodePudding user response:
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.