我有一个在 docker 容器(本地机器)中运行的服务.我可以在 Ambari 服务配置中看到服务 URL.
I have a service running in a docker container (local machine). I can see the service URL in the Ambari service config.
现在我想使用本地开发环境连接到该服务.
Now I want to connect to that service using my local development environment.
我发现我可以在容器内连接到该 URL,但是当我在本地外部使用该 URL 时,连接被拒绝.
I found I can connect to that within the container but when I use that URL outside in my local I get connection refused.
Cause: org.apache.http.conn.HttpHostConnectException: Connect to xx.xx.xx:12008 [xx.xx.xx/195.169.98.101] failed: Connection refused如何从外部连接到容器内运行的服务?在我的例子中,代码在我的本地机器上执行.
How to connect to a service running inside a container from outside? In my case code execute in my local machine.
推荐答案如果您的容器已将其端口映射到 VM 12008 端口,则您需要确保在 VirtualBox 连接设置中已转发端口 12008,正如我所提到的在如何将mysql工作台连接到在docker内部运行mysql?"
If your container has mapped its port on the VM 12008 port, you would need to make sure you have port forwarded 12008 in your VirtualBox connection settings, as I mention in "How to connect mysql workbench to running mysql inside docker?"
VBoxManage controlvm "boot2docker-vm" --natpf1 "tcp-port12008 ,tcp,,12008,,12008" VBoxManage controlvm "boot2docker-vm" --natpf1 "udp-port12008 ,udp,,12008,,12008"更多推荐
从外部连接到在 docker 容器内运行的服务
发布评论