I am currently trying to connect to rabbitmq inside a docker container from a node.js application outside of docker. Currently, I am receiving TIMEOUT errors when I try to send a message to rabbitmq.
Here are the docker file settings for rabbitmq:
rabbitmq:
container_name: "my_rabbitmq"
hostname: "rabbitmq"
tty: true
image: rabbitmq:management
ports:
- 15672:15672
- 15671:15671
- 5672:5672
volumes:
- /rabbitmq/lib:/var/lib/rabbitmq
- /rabbitmq/log:/var/log/rabbitmq
- /rabbitmq/conf:/etc/rabbitmq/
I am using the following connection string to access docker:
amqp://guest:guest@localhost:5672
I can access and login to the web admin port at 15672 with no problem and I am currently testing on my local machine(mac os x). Are there any special network configurations needed to access a dockerized rabbitmq instance from an application that is currently external to docker?
UPDATE:
Not sure if this makes a difference. When I did a docker-compose logs rabbitmq I see the following entry:
[info] <0.556.0> accepting AMQP connection <0.556.0> (172.20.0.1:58826 -> 172.20.0.2:5672)
[info] <0.556.0> connection <0.556.0> (172.20.0.1:58826 -> 172.20.0.2:5672): user 'guest' authenticated and granted access to vhost '/'
client unexpectedly closed TCP connection
I am not sure what this 172.20.0.2 IP address is. My connection string is currently set to access localhost and the port, which I mapped using the ports command in the yaml file.