docker - 将 Docker 容器部署到 Cloud Foundry 时,MQTT 端口连接被拒绝

标签 docker mqtt cloud-foundry

我已经构建了一个 docker 镜像,其中包含一个带有 MQTT 和 Mongodb 模块的 C++ 应用程序。当我尝试使用 Cloud Foundry 将其部署到我的云时,出现了以下错误:

ERR Failed to make TCP connection to port 1883: connection refused



鉴于 1883 是 MQTT 的监听端口。我在 CloudFoundry Docker 上找到了我唯一需要做的就是包括曝光 1883 在我已经完成的 Dockerfile 中。
谁能解释我到目前为止还没有考虑到什么?谢谢你的阅读。

最佳答案

引用 github commit 的声明.

You expose ports using the EXPOSE keyword in the Dockerfile or the --expose flag to docker run. Exposing ports is a way of documenting which ports are used, but does not actually map or open any ports. Exposing ports is optional.



如果您想在端口 1883 上访问 MQTT,请使用 -p option在您的 docker run 命令中。

在你的情况下
docker run -itd -p 1883:1883 mqtt-image-name

希望这可以帮助。

更新:

对不起我误会了,我通过了official博士。
EXPOSE应该在你的情况下工作。

你得到的错误ERR Failed to make TCP connection to port 1883: connection refused意味着您的应用程序或云代工厂有问题。

The error might be because your app either does not become available on port 1883 due to a failure, or that it takes longer than the specified healthcheck timeout for it to be up and running, thus failing the healthcheck.



请查看this了解更多信息。

希望这可以帮助。

关于docker - 将 Docker 容器部署到 Cloud Foundry 时,MQTT 端口连接被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56856987/

相关文章:

node.js - Node和MQTT,对消息做一些事情

node.js - 调度 mqtt 发布

bash - 如何编写杀死Docker容器的脚本?

linux - Docker容器上的Proftpd目录列表错误

docker - 如何在Docker群中的所有节点上删除镜像?

sockets - mqtt 协议(protocol)中订阅者的反馈消息

java - 部署在使用 JMS/AMQP 消息的 Cloud Foundry 上的应用程序

java - 12 Factor Apps - 将管理/管理任务作为一次性流程运行

tomcat - 云类型转换厂 : Set Environment Variables via Manifest. yml

docker - 如何使用 openshift 调试容器镜像