I'am trying to connect web- application, deployed from one container, to rabbitmq, deployed at another container.
By relying on this Connecting to RabbitMQ container with docker-compose , I created the following docker-compose:
version: '3'
services:
webapp:
container_name: chat
build:
context: .
depends_on:
- broker
links:
- broker
ports:
- "8080:8080"
broker:
container_name: rabbit_chat
image: rabbitmq:3-management
ports:
- "5672:5672"
- "15672:15672"
healthcheck:
test: ["CMD", "curl", "-f", "http://broker:15672"]
interval: 30s
timeout: 10s
retries: 5
webapp is a service of web-application, at which I prescribe following rabbitmq-properties:
host = broker
port = 15672
login = guest
password = guest
I changed 'broker' as a host, as in documentation recommended to connect containers by default-net, using the name of service in docker-compose. Also I tried to use "localhost" as host for connection.
And this does not work.
Additionally, Inspecting container "rabbit_chat" I see in output:
"Log": [
{
"Start": "2020-04-11T14:54:25.0988242Z",
"End": "2020-04-11T14:54:25.2920557Z",
"ExitCode": -1,
"Output": "OCI runtime exec failed: exec failed: container_linux.go:346: starting container process caused \"exec: \\\"curl\\\": executable file not found in $PATH\": unknown"
}
Also I tried to connect them by bridge-network. In this case I used IP of broker-container as host for requests. And it does not work to. When I connect my app with rabbitMQ on host (without containers) it works properly... So, I confused...
docker ps result:
a53833fb96c2 chat_webapp "catalina.sh run" About an hour ago Up About an hour 0.0.0.0:8080->8080/tcp chat
696cbafbd38b rabbitmq "docker-entrypoint.s…" About an hour ago Up About an hour 4369/tcp, 5671-5672/tcp, 15672/tcp, 25672/tcp rabbit_chat
Inside rabbit_chat-container I send request (webapp:8080) successfully. But when I send "curl broker:5672 --output - " inside chat-container, I received: "curl: (56) Recv failure: Connection reset by peer"
Inside rabbit_chat-container I run "ncat -v --listen 5672". And receive "Ncat: bind to :::5672: Address already in use. QUITTING.