当前位置:   article > 正文

Docker容器异常退出Exit(253)_docker exited 253

docker exited 253

容器异常退出,状态码为253

我遇到的情况为容器内挂载到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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76

原因分析

在此制作的镜像中,/home/rocketmq/目录下为空,在brocker运行之后,生成/log和/store目录,并对其中进行写入数据,此时使用docker-compose启动时,无法将卷挂载在/log和/store目录下。

问题解决

  • 重新制作镜像,在指定目录下创建目录(从根本解决问题)
  • 在挂载卷的时候,使用其根目录挂载,不区分log和store卷,直接挂在/home/rocketmq下(省事)

附成功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:/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

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/684439
推荐阅读
相关标签
  

闽ICP备14008679号