无法从父主机访问Docker容器中的托管应用程序 [英] Could not able to access the hosted application in Docker container from the parent host

查看:89
本文介绍了无法从父主机访问Docker容器中的托管应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个带有tomcat服务器的Docker容器。我已经启动了tomcat服务器,并且可以看到tomcat服务器成功启动的日志。
我使用以下命令运行容器



docker run -p 8092:8092 -dti cs2 / bin / bash



tomcat服务器启动后,我尝试从docker容器的父主机访问该站点。
我尝试使用以下网址访问该网站



// 192.168.99.100:8092 /



// 192.168.99.100:8092/cs/wbs



我无法点击任何上述网址。我总是看到无法访问该站点。

docker run -p 8092:8092 --network my-network -dti cs2 / bin / bash



当我docker ps ,我将获得以下容器信息,如屏幕截图中所示



请单击此处查看容器信息



对此有任何帮助

解决方案

您正在使用以下命令启动容器: / bin / bash ,该命令可能不会旋转服务器。您应该指定一个启动服务器的命令或根本不提供任何命令,该映像可能具有执行该操作的默认命令。



如果容器正在运行,可以使用 docker exec -it< container_name_or_id>附加到它/ bin / bash 并查看其中的内容。



此外,在屏幕上,您还有端口 8093 暴露给主机,而不是 8092


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

解决方案

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.

这篇关于无法从父主机访问Docker容器中的托管应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆