docker构建rockermq镜像

docker构建rockermq镜像

说明: RocketMQ的部署主要是broker和namesrv,broker是MQ的消息中转角色,负责存储消息,转发消息,一般称为Server。在 JMS 规范中称为 Provider。namesrv是一个几乎无状态节点,接受broker的Topic信息注册,为 producer 和 consumer 提供路由信息。

1、namesrv镜像

创建目录

/home/qw/docker/rocketmq/namesrv

#创建Dockerfile文件
vi Dockerfile

FROM java:8

ENV ROCKETMQ_VERSION 4.2.0

ENV ROCKETMQ_HOME  /opt/rocketmq-${ROCKETMQ_VERSION}
ENV JAVA_OPT " -Duser.home=/opt"

WORKDIR  ${ROCKETMQ_HOME}

RUN mkdir -p /opt/logs /opt/store

RUN curl https://dist.apache.org/repos/dist/release/rocketmq/${ROCKETMQ_VERSION}/rocketmq-all-${ROCKETMQ_VERSION}-bin-release.zip -o rocketmq.zip \
          && unzip rocketmq.zip \
          && rm rocketmq.zip \
          && cd ${ROCKETMQ_HOME}/bin \
          && sed -i 's#-Xms[0-9]\+[gm]#-Xms256m#' runserver.sh \
          && sed -i 's#-Xmx[0-9]\+[gm]#-Xmx256m#' runserver.sh \
          && sed -i 's#-Xmn[0-9]\+[gm]#-Xmn128m#' runserver.sh \
          && sed -i 's#-XX:MetaspaceSize=[0-9]\+[gm]#-XX:MetaspaceSize=64m#' runserver.sh \
          && sed -i 's#-XX:MaxMetaspaceSize=[0-9]\+[gm]#-XX:MaxMetaspaceSize=128m#' runserver.sh \
          && chmod +x ./mqnamesrv

CMD cd ${ROCKETMQ_HOME}/bin && sh mqnamesrv

EXPOSE 9876

VOLUME ["/opt/logs", "/opt/store"]

1.2、构建namesrv镜像

#构建镜像
docker build -t manualcall/rocketmq-namesrv:4.2.0 .

1.3、查看namesrv镜像

#查看docker镜像列表
docker images

#查看manualcall/rocketmq-namesrv镜像信息
docker inspect manualcall/rocketmq-namesrv:4.2.0

2、broker镜像

创建目录

/home/qw/docker/rocketmq/broker

#创建Dockerfile文件
vi Dockerfile


FROM java:8

ENV ROCKETMQ_VERSION 4.2.0

ENV ROCKETMQ_HOME  /opt/rocketmq-${ROCKETMQ_VERSION}
ENV JAVA_OPT " -Duser.home=/opt"

WORKDIR  ${ROCKETMQ_HOME}

RUN mkdir -p /opt/logs /opt/store

RUN curl https://dist.apache.org/repos/dist/release/rocketmq/${ROCKETMQ_VERSION}/rocketmq-all-${ROCKETMQ_VERSION}-bin-release.zip -o rocketmq.zip \
          && unzip rocketmq.zip \
          && rm rocketmq.zip \
          && cd ${ROCKETMQ_HOME}/bin \
          && sed -i 's#-Xms[0-9]\+[gm]#-Xms256m#' runbroker.sh \
          && sed -i 's#-Xmx[0-9]\+[gm]#-Xmx256m#' runbroker.sh \
          && sed -i 's#-Xmn[0-9]\+[gm]#-Xmn128m#' runbroker.sh \
          && chmod +x ./mqbroker

EXPOSE 10909 10911 10912

VOLUME ["/opt/logs", "/opt/store"]

CMD cd ${ROCKETMQ_HOME}/bin && sh mqbroker

#构建镜像
docker build -t manualcall/rocketmq-broker:4.2.0 .

#查看manualcall/rocketmq-broker镜像信息
docker inspect manualcall/rocketmq-broker:4.2.0

到此rocketmq主要的两个镜像搭建完成

参考 : https://my.oschina.net/u/2299686/blog/1618531

你可能感兴趣的:(rocketmq,docker镜像)