0

Scenario:

I use docker compose and i can't send notification minio to rabbitMQ I have the following rabbitmq.yml

version: '2'
services:
    rabbitmq:
        image: rabbitmq:3-management
        ports:
            # the management port
            - 5672:5672
            - 15672:15672
            # the stomp port
            - 61613:61613

and the following minio.yml

version: '2'

services:
  minio:
    image: 'bitnami/minio:latest'
    ports:
      - '9000:9000'
    environment:
      - MINIO_NOTIFY_AMQP_ENABLE=on   
      - MINIO_NOTIFY_AMQP_URL='amqp://guest:guest@192.168.1.2:15672'

    volumes:
      - 'minio_data:/data'

volumes:
  minio_data:
    driver: local

The problem is:

when i upload new file in minio server i don't receive notification in rabbitMQ.

I've already tried to change IP in MINIO_NOTIFY_AMQP_URL param to 127.0.0.1 but no result.

Is there a way to configure my docker-compose file (minio.yml, rabbit.yml) .

Community
  • 1
  • 1
yacin
  • 1
  • 1
  • 1
    I dont know `MINIO` but shouldn't it be `amqp://guest:guest@192.168.1.2:5672`. Port `15672` is the web management console, and port `5672` is rabbitmq listeningen. – Frank Nielsen Apr 11 '20 at 20:00

1 Answers1

1

You should probably use a docker network to connect both services. This could be done by specifiying network for both services.

You can then use the service name (in this case rabbitmq) as a host address:

MINIO_NOTIFY_AMQP_URL=amqp://guest:guest@rabbitmq:5672

Also note that the port should be 5672, just as @frank-nielsen recommended.

version: '2'

services:
  minio:
    image: 'bitnami/minio:latest'
    ports:
      - '9000:9000'
    network:
      - backend
    environment:
      - MINIO_NOTIFY_AMQP_ENABLE=on   
      - MINIO_NOTIFY_AMQP_URL='amqp://guest:guest@rabbitmq:5672'

    volumes:
      - 'minio_data:/data'

network:
  backend:
    external: true

volumes:
  minio_data:
    driver: local

and the same for your rabbitmq config.

You will have to create the network using

docker network create backend
Jonas
  • 725
  • 5
  • 23
  • I have properly set these up but minio still cannot dial tcp connection. ‍‍‍minio1_1 | Error: dial tcp 172.18.0.2:5672: connect: connection refused (*net.OpError)‍‍‍ – Matin Zadeh Dolatabad May 31 '21 at 13:41
  • How do you run rabbitmq? Is it also running in docker? Make sure that they share the same network. – Jonas Jun 01 '21 at 14:49
  • They are accessible in the same docker netwok and also I can ping 2 container with their hostname but minio fails in first try when rabbitmq is not ready and it does not try again later when the rabbitmq is up. – Matin Zadeh Dolatabad Jun 04 '21 at 07:13
  • Okay, so the problem is not that minio is unable to connect to the IP but rather that at the time of connecting, rabbitmq is not yet ready. To avoid this, you can use depends_on in combination with a health check on rabbitmq: https://docs.docker.com/compose/compose-file/compose-file-v3/#depends_on – Jonas Jun 05 '21 at 08:44
  • As for the healthcheck, you might want to try this: https://devops.stackexchange.com/questions/12092/docker-compose-healthcheck-for-rabbitmq#12200 – Jonas Jun 05 '21 at 08:47
  • Hm, seems like starting with docker-compose version 3, this feature has been removed and depends_on does no longer obey healthchecks. However, I am unable to test this currently. – Jonas Jun 05 '21 at 08:52