一、拉取docker镜像

  1. docker pull foxiswho/rocketmq:server
  2. docker pull foxiswho/rocketmq:broker

二、启动 server

  1. docker run -d -p 9876:9876 --name rmq-server foxiswho/rocketmq:server

三、启动 broker

  1. docker run -d -p 10911:10911 -p 10909:10909 --name rmq-broker --link rmq-server:namesrv -e "NAMESRV_ADDR=namesrv:9876" -e "JAVA_OPTS=-Duser.home=/opt" -e "JAVA_OPT_EXT=-server -Xms128m -Xmx128m -Xmn128m" -v f:/Repository-Docker/rmq/conf/broker.conf:/etc/rocketmq/broker.conf foxiswho/rocketmq:broker
  1. docker run -d -p 10911:10911 -p 10909:10909 --name rmq-broker --link rmq-server:namesrv \
  2. -e "NAMESRV_ADDR=namesrv:9876" \
  3. -e "JAVA_OPTS=-Duser.home=/opt" \
  4. -e "JAVA_OPT_EXT=-server -Xms128m -Xmx128m -Xmn128m" \
  5. -v f:/Repository-Docker/rmq/conf/broker.conf:/etc/rocketmq/broker.conf \
  6. foxiswho/rocketmq:broker

broker.conf

  1. # Licensed to the Apache Software Foundation (ASF) under one or more
  2. # contributor license agreements. See the NOTICE file distributed with
  3. # this work for additional information regarding copyright ownership.
  4. # The ASF licenses this file to You under the Apache License, Version 2.0
  5. # (the "License"); you may not use this file except in compliance with
  6. # the License. You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. brokerClusterName = DefaultCluster
  16. brokerName = broker-a
  17. brokerId = 0
  18. deleteWhen = 04
  19. fileReservedTime = 48
  20. brokerRole = ASYNC_MASTER
  21. flushDiskType = ASYNC_FLUSH
  22. # 指定启动ip,代码连接mq时候使用 本机IP
  23. brokerIP1 = 172.20.111.110

四、启动 console

  1. docker run --name rmq-console --link rmq-server:namesrv -e "JAVA_OPTS=-Drocketmq.namesrv.addr=namesrv:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false" -p 8180:8080 -t styletang/rocketmq-console-ng

说明

  • 运行成功访问:ip:8081