docker-compose.yml 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. version: "3.3"
  2. configs:
  3. rabbitmq.config:
  4. external:
  5. name: rabbitmq_rabbit1.config
  6. rabbitmq_enabled_plugins:
  7. external:
  8. name: rabbitmq_enabled_plugins
  9. ## docker swarm 部署,swarm名称为rabbitmq,则hostname 为rabbitmq_rabbit,容器之间可通过hostname互相访问
  10. ## 如果docker-compose 部署,则为容器名称,需保证在同一个网络内
  11. services:
  12. rabbit1:
  13. image: tuonina/rabbitmq:3-management.cluster
  14. hostname: rabbitmq_rabbit1
  15. environment:
  16. RABBITMQ_ERLANG_COOKIE: "rabbitmq"
  17. RABBITMQ_NODENAME: rabbitmq_rabbit1
  18. RABBITMQ_ENABLED_PLUGINS_FILE: "/rabbitmq_enabled_plugins" # 指定启用的插件,前提是插件必须在指定的位置,能访问得到
  19. ports:
  20. - "4369:4369"
  21. - "5671:5671"
  22. - "5672:5672"
  23. - "15671:15671"
  24. - "15672:15672"
  25. - "25672:25672"
  26. deploy:
  27. labels:
  28. - "mq.master=true"
  29. volumes:
  30. - /data/db/rabbit:/var/lib/rabbitmq/mnesia
  31. configs:
  32. - rabbitmq.config
  33. - rabbitmq_enabled_plugins
  34. rabbit2:
  35. image: tuonina/rabbitmq:3-management.cluster
  36. hostname: rabbitmq_rabbit2
  37. depends_on:
  38. - rabbit1
  39. environment:
  40. RABBITMQ_ERLANG_COOKIE: "rabbitmq"
  41. RABBITMQ_NODENAME: rabbitmq_rabbit2
  42. RABBITMQ_ENABLED_PLUGINS_FILE: "/rabbitmq_enabled_plugins"
  43. volumes:
  44. - /data/db/rabbit:/var/lib/rabbitmq/mnesia
  45. configs:
  46. - rabbitmq.config
  47. - rabbitmq_enabled_plugins