I'm trying to run rabbitMQ using docker-compose, but the service is always starting or unhealthy.
rabbit is running fine, so I suspect there is something wrong with my health check.

Running the healthcheck command locally does return a value.

> curl -f http://localhost:5672
AMQP    %

But docker-compose ps always says the service is unhealthy (or starting, before it runs out of time).

> docker-compose ps
docker-entrypoint.sh rabbi ...   Up (unhealthy)   15671/tcp

Here is what my docker-compose.yml file looks like.

# docker-compose.yml
version: '2.3' # note: I can't change this version, must be 2.3


    hostname: 'rabbit'
    image: rabbitmq:3.8.5-management
      test: ["CMD", "curl", "-f", "http://localhost:5672"]
      interval: 30s
      timeout: 30s
      retries: 3
      - '5672:5672'
      - '15672:15672'
      - 'rabbit-data:/var/lib/rabbitmq/mnesia/'
      - rabbitmq

    driver: bridge

I have also tried using nc instead of curl in the healthcheck, but got the same result.

  test: [ "CMD", "nc", "-z", "localhost", "5672" ]

From https://github.com/docker-library/rabbitmq/issues/326

3 Answers 3


You could use the command rabbitmq-diagnostics -q ping in case you just need a basic check.

  test: rabbitmq-diagnostics -q ping
  interval: 30s
  timeout: 30s
  retries: 3

More information on how to run more advanced health checks could be found here

  • Thanks a million, that's exactly what I needed! The docs mention each stage builds on the previous. >"This includes the stage 1 check plus ..." Do you know if you have to chain the commands? or does each command implicitly cover the previous one? e.g. which do I need for stage 2? 1. rabbitmq-diagnostics -q ping && rabbitmq-diagnostics -q status 2. rabbitmq-diagnostics -q status
    – con--
    Aug 13, 2020 at 11:20
  • 2
    Option 2 should be enough. Every time the status command returns OK, the ping command would have been successful too. But, the status makes some additional checks.
    – pmodernell
    Aug 18, 2020 at 14:56
  • Memory alarms are not detected here, ex: "memory resource limit alarm set on ... Publishers will be blocked until this alarm clears" Jul 20 at 7:22

If rabbitmq-diagnostics -q ping not working for you, check this

  test: rabbitmq-diagnostics check_port_connectivity
  interval: 1s
  timeout: 3s
  retries: 30

In my example I also reduced interval.


I will go with this, I want to raise issues like "Publishers will be blocked until this alarm clears":

        test: rabbitmq-diagnostics -q status && rabbitmq-diagnostics -q check_local_alarms
        interval: 60s
        timeout: 30s
        retries: 3
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Jul 20 at 10:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.