Rabbitmq从Docker容器到本地主机的连接被拒绝

前端之家收集整理的这篇文章主要介绍了Rabbitmq从Docker容器到本地主机的连接被拒绝 前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我有一个运行Java进程的Docker容器,该容器试图连接到在本地主机上运行的Rabbitmq.

这是我到目前为止已完成的步骤:

在我的本地机器上(运行Docker版本1.13.0-rc3的MacBook,在关闭防火墙的情况下构建4d92237)

>我已经更新了Rabbitmq_env.conf文件,删除了RABBITMQ_NODE_IP_ADDRESS,因此我不受本地主机连接的束缚,并且我拥有管理员Rabbitmq用户. (不尝试使用来宾用户)
>我通过本地计算机上的telnet对此进行了测试,但telnet< local-ip>没有任何问题. 5672

在我的Docker容器中

>能够ping本地IP并卷曲Rabbitmq管理员api
curl -i -u用户名:密码http:// local-ip:15672 / api / vhosts成功返回

[{“name”:”/”,”tracing”:false}]

>当我尝试从容器内进行telnet时

“Connection closed by foreign host”

>查看rabbitmq.logs

=错误报告====
关闭AMQP连接< 0.30526.1> (本地IP:53349->本地IP:5672):
{handshake_timeout,handshake}

我的java stacktrace以防万一

Caused by: java.net.ConnectException: Connection refused (Connection >refused)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at >java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at >java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.>java:206)
at >java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at >com.rabbitmq.client.impl.FrameHandlerFactory.create(FrameHandlerFactory.ja>va:32)
at >com.rabbitmq.client.impl.recovery.RecoveryAwareAMQConnectionFactory.newCon>nection(RecoveryAwareAMQConnectionFactory.java:35)

Docker网络检查桥

[
{
“Name”: “bridge”,
“Id”: “716f935f19a107225650a95d06eb83d4c973b7943b1924815034d469164affe5”,
“Created”: “2016-12-11T15:34:41.950148125Z”,
“Scope”: “local”,
“Driver”: “bridge”,
“EnableIPv6”: false,
“IPAM”: {
“Driver”: “default”,
“Options”: null,
“Config”: [
{
“Subnet”: “172.17.0.0/16”,
“Gateway”: “172.17.0.1”
}
]
},
“Internal”: false,
“Attachable”: false,
“Containers”: {
“9722a49c4e99ca5a7fabe56eb9e1c71b117a1e661e6c3e078d9fb54d7d276c6c”: {
“Name”: “testing”,
“EndpointID”: “eedf2822384a5ebc01e5a2066533f714b6045f661e24080a89d04574e654d841”,
“MacAddress”: “02:42:ac:11:00:02”,
“IPv4Address”: “172.17.0.2/16”,
“IPv6Address”: “”
}
},
“Options”: {
“com.docker.network.bridge.default_bridge”: “true”,
“com.docker.network.bridge.enable_icc”: “true”,
“com.docker.network.bridge.enable_ip_masquerade”: “true”,
“com.docker.network.bridge.host_binding_ipv4”: “0.0.0.0”,
“com.docker.network.bridge.name”: “docker0”,
“com.docker.network.driver.mtu”: “1500”
},
“Labels”: {}
}
]

我想念什么?

最佳答案
对我来说,这很好!

I have been installed the image docker pull rabbitmq:3-management

并运行

docker run -d --hostname haroldjcastillo --name rabbit-server -e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=admin2017 -p 5672:5672 -p 15672:15672 rabbitmq:3-management

the most important is to add the connection and management ports -p 5672:5672 -p 15672:15672

看到您在Docker中托管

docker-machine ip

返回我的情况:

192.168.99.100

Go to management http://192.168.99.100:15672

For Spring Boot you can configure this or works good for another connections

spring.rabbitmq.host=192.168.99.100
spring.rabbitmq.username=admin
spring.rabbitmq.password=admin2017
spring.rabbitmq.port=5672

最好的祝愿

猜你在找的Docker相关文章