emqx5.0 docker stack 方式部署失败

环境信息

  • EMQX 版本:emqx/emqx:5.0.4
  • 操作系统及版本:docker
  • 其他

问题描述

docker stack 方式部署时,如果将 * /opt/emqx/data和 * /opt/emqx/etc挂载出去的话就会启动不起来。

麻烦提供下相关日志信息

escript: exception throw: {emqx_conf_schema,[#{kind => validation_error,

                                  path => "node.data_dir",


                                  reason => mandatory_required_field,


                                  value => undefined}]}

in function hocon_tconf:assert_no_error/2 (hocon_tconf.erl, line 1124)

in call from hocon_tconf:map/4 (hocon_tconf.erl, line 295)

in call from hocon_cli:get_values/3 (hocon_cli.erl, line 194)

in call from hocon_cli:multi_get/2 (hocon_cli.erl, line 182)

in call from escript:run/2 (escript.erl, line 750)

in call from escript:start/1 (escript.erl, line 277)

in call from init:start_em/1

in call from init:do_boot/3

打开目录映射就出错,配置如下:

version: '3.7'
services:
  emqx:
    image: emqx/emqx:5.0.4
    restart: always
    hostname: emqx
    privileged: true  # 解决权限问题
    volumes: 
      #- /projects/emqx/data:/opt/emqx/data/
      #- /projects/emqx/etc:/opt/emqx/etc/
      - /projects/emqx/log:/opt/emqx/log/
    deploy:
      replicas: 1
      restart_policy:
        condition: on-failure
      update_config:
        parallelism: 1 # 每次更新1个副本
        delay: 30s # 每次更新间隔 
        monitor: 180s # 单次更新多长时间后没有结束则判定更新失败
        max_failure_ratio: 0.1 # 更新时能容忍的最大失败率
        order: start-first # 更新顺序为新任务启动优先
    ports:
      - 8860:1883
      - 8861:8883
      - 8862:8083
      - 8863:8080
      - 8865:18083
    environment:
      - TZ=Asia/Shanghai
      - EMQX_NAME=emqx
      - EMQX_HOST=node1.emqx.io	  
      - EMQX_MQTT__MAX_PACKET_SIZE=20MB
      - EMQX_ALLOW_ANONYMOUS=false
      - EMQX_ACL_NOMATCH=deny
      - EMQX_NODE_PROCESS__LIMIT=2097152
      - EMQX_NODE_MAX__PORTS=1048576
      - EMQX_LOADED_PLUGINS="emqx_management,emqx_recon,emqx_retainer,emqx_dashboard,emqx_auth_mnesia,emqx_auth_http"
      - EMQX_LISTENER_TCP_EXTERNAL_ACCEPTORS=64
      - EMQX_LISTENER_TCP_EXTERNAL_MAX__CONNECTIONS=1024000
      - EMQX_ZONE__EXTERNAL__MAX_INFLIGHT=256
      - EMQX_ZONE__EXTERNAL__RETRY_INTERVAL=30s
      - EMQX_ZONE__EXTERNAL__MAX_MQUEUE_LEN=0
    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "3"
    networks:
      - wk-core
networks:  
 wk-core:
   external: true

试试不要挂etc目录。如果要挂的话,你得把zip包下载的etc/* 全copy到etc里面。

可以了,需要运行两次。第一次无挂载运行,然后把etc下的文件复制出来,第二次再挂载到物理目录上并把前次etc复制出来的内容复制进去。

1 个赞

有空安排写个完整的玩docker 最佳实践。我看你直接ENV来设置,一般用了ENV的话,就不在需要etc下修改东西的。所以把etc挂出去,也没什么用途。