官方docker项目地址:
https://github.com/apache/incubator-rocketmq-externals
里面有rocketmq的docker运行文档
如果同时需要docker运行console需要注意一个问题
下面是官方文档中运行console的命令,里面的JAVA_OPTS参数是不正确的,不知道是不是版本原因
docker run -e
"JAVA_OPTS=-Drocketmq.namesrv.addr=127.0.0.1:9876
-Dcom.rocketmq.sendMessageWithVIPChannel=false"
-p 8080:8080 -t styletang/rocketmq-console-ng
按照这个命令运行的话会报错 connect to <null> failed
, 如图
对比直接在服务器上运行的命令,把其中java_opts改为如下
docker run -e
"JAVA_OPTS=-Drocketmq.config.namesrvAddr=127.0.0.1:9876
-D" -p 8080:8080 -t styletang/rocketmq-console-ng
再次运行,没有报错。
下面是我启动namesrv,broker,console用的docker-compose.yml
version: '2'
namesrv:
image: apache/incubator-rocketmq-namesrv:4.0.0-incubating
net: "host" # 涉及到一些特殊的服务,所以用的是host,正常情况建议不要使用host网络
volumes:
- /data/rocket/namesrv/opt/logs:/opt/logs # 保留日志到宿主机
- /data/rocket/namesrv/opt/store:/opt/store
- /etc/localtime:/etc/localtime:ro # 修改容器内的时区和宿主机一样
ports:
- "9876:9876"
broker:
image: apache/incubator-rocketmq-broker:4.0.0-incubating
net: "host"
environment:
NAMESRV_ADDR: xx.xx.xx.xx:9876 # namesrv的地址
volumes:
- /data/rocket/broker/opt/logs:/opt/logs # 保留日志
- /data/rocket/broker/opt/store:/opt/store # 保留数据到宿主机
- /etc/localtime:/etc/localtime:ro
#links:
# - namesrv:namesrv
ports:
- "10911:10911"
- "10909:10909"
console:
image: styletang/rocketmq-console-ng:latest
net: "host"
volumes:
- /etc/localtime:/etc/localtime:ro
ports:
- "8080:8080"
#links:
# - namesrv:namesrv
environment:
JAVA_OPTS: -Drocketmq.config.namesrvAddr=xx.xx.xx.xx:9876
来源:CSDN
作者:MMMMMMMMMMemory
链接:https://blog.csdn.net/mayifan0/article/details/77336900