问题
I have created a Docker container with a tomcat server. I have started the tomcat server and i can see the logs that tomcat server started successfully. I used the following command to run the container
docker run -p 8092:8092 -dti cs2 /bin/bash
Once the tomcat server started, i tried to access the site from the parent host of the docker container. I tried accessing the site using the following url's
//192.168.99.100:8092/
//192.168.99.100:8092/cs/wbs
I am not able to hit any above url's. I always see that site cannot be reached.
I also tried by adding my container to an newly created network like below, still no luck on accessing the site
docker run -p 8092:8092 --network my-network -dti cs2 /bin/bash
When i docker ps, i get the following container information as like in the screenshot
Please click here to see the container information
Any help on this would be appreciable
回答1:
You are starting the container with the command: /bin/bash
, which probably doesn't spin server. You rather should specify a command that starts the server or don't provide it at all, the image probably has default command that does just that.
If container is running you can attach to it with docker exec -it <container_name_or_id> /bin/bash
and see what's there.
Also, on the screen, you have port 8093
exposed to the host, not 8092
.
来源:https://stackoverflow.com/questions/46614520/could-not-able-to-access-the-hosted-application-in-docker-container-from-the-par