Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using rabbitmq with docker in production

I currently have a small server running in a docker container, the server uses RabbitMQ which is being run by docker-compose using the DockerHub image.

It is running nicely, but I'm worried that it may not be properly configured for production (production being a simple server, without clustering or anything fancy). In particular, I'm worried about the disk space limit described at RabbitMQ production checklist.

I'm not sure how to configure these things through docker-compose, as the env variables defined by the image seem to be quite limited.

My docker-compose file:

version: '3.4'
services:
  rabbitmq:
    image: rabbitmq:3-management-alpine
    ports:
      - "5672:5672"
      - "15672:15672"
    volumes:
      - rabbitmq:/var/lib/rabbitmq
    restart: always
    environment:
      - RABBITMQ_DEFAULT_USER=user
      - RABBITMQ_DEFAULT_PASS=secretpassword

  my-server:
   # server config here

volumes:
  rabbitmq:

networks:
  server-network:
    driver: bridge
like image 791
angrykoala Avatar asked Jul 29 '19 22:07

angrykoala


People also ask

How do I use RabbitMQ with docker?

Open a terminal, navigate to your rabbitmq-go folder and run docker-compose up . This command will pull the rabbitmq:3-management-alpine image, create the container rabbitmq and start the service and webUI. You should see something like this: Once you see this, open your browser and head over to http://localhost:15672.

Is RabbitMQ stateful?

RabbitMQ requires using a Stateful Set to deploy a RabbitMQ cluster to Kubernetes. The Stateful Set ensures that the RabbitMQ nodes are deployed in order, one at a time.


1 Answers

disk_free_limit is set in /etc/rabbitmq/rabbitmq.conf, seems there is no environment available here.

So, you just need to override the rabbitmq.conf with your own one with docker bind mount volume to make your aim.

For your case, if you enter into the rabbitmq container, you can see:

shubuntu1@shubuntu1:~$ docker exec  some-rabbit cat /etc/rabbitmq/rabbitmq.conf
loopback_users.guest = false
listeners.tcp.default = 5672

So you just need to add disk_free_limit.absolute = 1GB local rabbitmq.conf & mount it to container to override the default configure, full example as next:

rabbitmq.conf:

loopback_users.guest = false
listeners.tcp.default = 5672
disk_free_limit.absolute = 1GB

docker-compose.yaml:

version: '3.4'
services:
  rabbitmq:
    image: rabbitmq:3-management-alpine
    ports:
      - "5672:5672"
      - "15672:15672"
    volumes:
      - rabbitmq:/var/lib/rabbitmq
      - ./rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf

volumes:
  rabbitmq:

networks:
  server-network:
    driver: bridge

check if have effect now:

$ docker-compose up -d
$ docker-compose logs rabbitmq | grep "Disk free limit"
rabbitmq_1  | 2019-07-30 04:51:40.609 [info] <0.241.0> Disk free limit set to 1000MB

You can see disk free limit already set to 1GB.

like image 193
atline Avatar answered Nov 10 '22 20:11

atline