0

I'm facing next problem. I want to run rabbitmq in docker container. When I run docker image with next command:

docker run -it --rm --name rabbit -e RABBITMQ_DEFAULT_USER=aaa -e RABBITMQ_DEFAULT_PASS=aaa -p 5672:5672 -p 15672:15672 rabbitmq:3-management

It works just fine. But I cannot run it in docker-compose. There is my docker-compose.yml:

version: "3"

services:
  rabbitmq3:
    image: rabbitmq:3-management
    container_name: rabbitmq
    environment:
      - RABBITMQ_DEFAULT_USER=aaa
      - RABBITMQ_DEFAULT_PASS=aaa
    ports:
      - 15672:15672
      - 5672:5672

I use docker-compose up --build command. Logs are ok, but I cannot open rabbitmq at localhost:15672.

Versions are:

docker-compose version 1.24.0, build 0aa59064

Docker version 19.03.5, build 633a0ea838

Edit

I think, logs are fine, but I'm not sure. Please, check it out here

4
  • github.com/Gsantomaggio/rabbitmqexample/blob/master/… Commented Jul 27, 2020 at 14:04
  • 1
    Your example docker-compose.yml works fine for me with no changes. I note that there is a bit of delay between starting the container and rabbitmq actually being ready to service requests. Commented Jul 27, 2020 at 14:04
  • 1
    Yes, I've waited for several minutes, and still no changes... Commented Jul 27, 2020 at 14:15
  • looks like rabbitmq starting up. please check host IP and try opening port using that instead of localhost Commented Jul 27, 2020 at 18:16

3 Answers 3

5

I'm sorry to bump this one up a year later, but I've just ran into the same problem, so I hope it helps someone anyway :)

TL;DR Using the rabbitmq:3-management-alpine image instead of rabbitmq:3-management solved this for me.

Here is my docker-compose.yml:

version: "3.9"
services:
  my-rabbit:
    image: rabbitmq:3-management-alpine
    container_name: my-rabbit
    hostname: my-rabbit-host
    ports:
      - "15672:15672"
      - "5672:5672"
    volumes:
      - "./rabbitdata:/var/lib/rabbitmq"

After running docker compose --detach the management plugin interface and the broker itself become available at http://localhost:15672 (tcp localhost:5672 for broker)

The long story

Using rabbitmq:3-management image with docker-compose.yml produces the following output in docker logs: Log output for rabbitmq:3-management with docker-compose.yml

The output stops after the last line

01 19:20:07.852760+00:00 [noti] <0.299.0> WAL: ra_log_wal init, open tbls: ra_log_open_mem_tables, closed tbls: ra_log_closed_mem_tables

and neither broker nor management plugin are available.

However, after running the following command (using the same arguments as in docker-compose.yml)

docker run -d --hostname my-rabbit-host -p 15672:15672 -p 5672:5672 --name my-rabbit -v rabbitdata:/var/lib/rabbitmq rabbitmq:3-management

the log actually looks quite different:

Docker log after running rabbitmq:3-management using shell command

One might notice, that the server is actually started, and after that both broker and management UI become accessible!

Now, if we change the image in docker-compose.yml from rabbitmq:3-management to rabbitmq:3-management-alpine (see TL;DR example) and run docker compose up --detach, the log output looks pretty much like it was with docker run ... rabbitmq:3-management, and, once again, both broker interface and the management plugin interface work just fine at localhost using ports 5672 and 15672 respectively.

Sign up to request clarification or add additional context in comments.

1 Comment

thx so much.. i've been struggling with this for 2 days..geez
1

Please wait for while sometime rabbitmq take times to start up try this working for me

version: "3"

services:

  rabbitmq:
    image: rabbitmq:3-management
    command: rabbitmq-server
    expose:
      - 5672
      - 15672
    healthcheck:
      test: [ "CMD", "nc", "-z", "localhost", "5672" ]
      interval: 5s
      timeout: 15s
      retries: 1

  worker:
    image: worker
    restart: on-failure
    depends_on:
      - rabbitmq

1 Comment

Yeah, I've waited, but nothing changed. Can you, please, check out my log file? Maybe there is an issue, which I don't see
1

Running RabbitMQ using docker-compose.yml is quiet simple

docker-compose.yml

version: '2'
services:
  rabbit:
    image: rabbitmq:3.7.2-management
    environment:
      RABBITMQ_DEFAULT_VHOST: rabbitmq-host
    ports:
      - 5672:5672
      - 15672:15672

you can simply start the docker compose file by using the command

docker-compose up

wait for 30 seconds and hit http://localhost:15672/ in you browser. You can use guest as both default username and password. You can find a sample Spring Boot RabbitMQ example in the below GitHub

https://github.com/nidhishkrishnan/messaging

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.