赞
踩
我遇到的情况为容器内挂载到docker卷的目录不存在,导致挂载失败,容器异常退出
使用rocketmq官方工具制作指定版本镜像,使用docker-compose启动nameSrv1+MasterBroker1+SlaveBroker*1,将broker的日志目录和存储目录挂载在docker卷上,具体docker-compose如下。
version: '2' services: mq_nsrv: image: apacherocketmq/rocketmq:4.3.1 container_name: rocketmq_namesrv ports: - 9876:9876 volumes: - mq_nsrv:/home/rocketmq/logs - /etc/localtime:/etc/localtime - /etc/timezone:/etc/timezone command: sh mqnamesrv networks: - mq_net mq_broker_m: image: apacherocketmq/rocketmq:4.3.1 container_name: rocketmq_broker_m links: - mq_nsrv depends_on: - mq_nsrv environment: JAVA_OPTS: " -Duser.home=/opt -Dlogging.level.root=info" JAVA_OPT_EXT: "-server -Xms256m -Xmx256m -Xmn256m" ports: - 10909:10909 - 10911:10911 - 10912:10912 volumes: - /etc/localtime:/etc/localtime - /etc/timezone:/etc/timezone - master_broker_log:/home/rocketmq/log - master_broker_store:/home/rocketmq/store - ./broker_m.conf:/opt/rocketmq-4.3.1/conf/broker.conf command: sh mqbroker -c /opt/rocketmq-4.3.1/conf/broker.conf networks: - mq_net mq_broker_s: image: apacherocketmq/rocketmq:4.3.1 container_name: rocketmq_broker_s links: - mq_nsrv depends_on: - mq_nsrv environment: JAVA_OPTS: " -Duser.home=/opt -Dlogging.level.root=info" JAVA_OPT_EXT: "-server -Xms256m -Xmx256m -Xmn256m" ports: - 11909:10909 - 11911:10911 - 11912:10912 volumes: - /etc/localtime:/etc/localtime - /etc/timezone:/etc/timezone - slave_broker_log:/home/rocketmq/log - slave_broker_store:/home/rocketmq/store - ./broker_s.conf:/opt/rocketmq-4.3.1/conf/broker.conf command: sh mqbroker -c /opt/rocketmq-4.3.1/conf/broker.conf networks: - mq_net volumes: mq_nsrv: driver: local master_broker_log: driver: local master_broker_store: driver: local slave_broker_log: driver: local slave_broker_store: driver: local networks: mq_net: driver: bridge
在此制作的镜像中,/home/rocketmq/目录下为空,在brocker运行之后,生成/log和/store目录,并对其中进行写入数据,此时使用docker-compose启动时,无法将卷挂载在/log和/store目录下。
version: '2' services: mq_nsrv: image: apacherocketmq/rocketmq:4.3.1 container_name: rocketmq_namesrv ports: - 9876:9876 volumes: - mq_nsrv:/home/rocketmq/logs - /etc/localtime:/etc/localtime - /etc/timezone:/etc/timezone command: sh mqnamesrv networks: - mq_net mq_broker_m: image: apacherocketmq/rocketmq:4.3.1 container_name: rocketmq_broker_m links: - mq_nsrv depends_on: - mq_nsrv environment: JAVA_OPTS: " -Duser.home=/opt -Dlogging.level.root=info" JAVA_OPT_EXT: "-server -Xms256m -Xmx256m -Xmn256m" ports: - 10909:10909 - 10911:10911 - 10912:10912 volumes: - /etc/localtime:/etc/localtime - /etc/timezone:/etc/timezone - master_broker:/home/rocketmq - ./broker_m.conf:/opt/rocketmq-4.3.1/conf/broker.conf command: sh mqbroker -c /opt/rocketmq-4.3.1/conf/broker.conf networks: - mq_net mq_broker_s: image: apacherocketmq/rocketmq:4.3.1 container_name: rocketmq_broker_s links: - mq_nsrv depends_on: - mq_nsrv environment: JAVA_OPTS: " -Duser.home=/opt -Dlogging.level.root=info" JAVA_OPT_EXT: "-server -Xms256m -Xmx256m -Xmn256m" ports: - 11909:10909 - 11911:10911 - 11912:10912 volumes: - /etc/localtime:/etc/localtime - /etc/timezone:/etc/timezone - slave_broker:/home/rocketmq - ./broker_s.conf:/opt/rocketmq-4.3.1/conf/broker.conf command: sh mqbroker -c /opt/rocketmq-4.3.1/conf/broker.conf networks: - mq_net volumes: mq_nsrv: driver: local master_broker: driver: local slave_broker: driver: local networks: mq_net: driver: bridge
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。