emqx / emqx

The most scalable open-source MQTT broker for IoT, IIoT, and connected vehicles
https://www.emqx.com/
Other
14.16k stars 2.25k forks source link

emqx does not appear to use docker mounted configuration files #11489

Closed GuanTu closed 1 year ago

GuanTu commented 1 year ago

What happened?

emqx does not appear to use docker mounted configuration files

What did you expect to happen?

I hope you can help me see if my use is wrong

How can we reproduce it (as minimally and precisely as possible)?

docker-stack.yaml

version: '3'

services:
  emqx:
    image: emqx:5.1.3
    deploy:
      mode: global
      placement:
        constraints: [node.role == manager]
    environment:
      - "TZ=Asia/Shanghai"
    volumes:
      - emqx.conf:/opt/emqx/etc/emqx.conf
      - emqx_data:/opt/emqx/data
    networks:
      emqx_host: {}

volumes:
  emqx_data:

networks:
  emqx_host:
    external:
      name: host

emqx.conf

## NOTE:
## This config file overrides data/configs/cluster.hocon,
## and is merged with environment variables which start with 'EMQX_' prefix.
##
## Config changes made from EMQX dashboard UI, management HTTP API, or CLI
## are stored in data/configs/cluster.hocon.
## To avoid confusion, please do not store the same configs in both files.
##
## See https://www.emqx.io/docs/en/v5.0/configuration/configuration.html for more details.
## Configuration full example can be found in etc/examples

node {
  ## name = "emqx@127.0.0.1"
  name = "emqx@192.168.12.5"
  cookie = "46fb19e6999c4c64be0acf94b96325c6"
  data_dir = "data"
}

cluster {
    ## Human-friendly name of the EMQX cluster.
    name = emqxcl

    ## Service discovery method for the cluster nodes
    discovery_strategy = static

    ## If true, the node will try to heal network partitions automatically
    autoheal = true

    ## List EMQX node names in the static cluster
    ## static.seeds = [[192.168.12.6 192.168.12.5]]
    static.seeds = ["emqx@192.168.12.6","emqx@192.168.12.5"]
}

dashboard {
    listeners.http {
        bind = 18083
    }
}

run command:

docker stack deploy -c emqx-stack.yaml emqx

Anything else we need to know?

Using a docker swarm cluster, my environment only has two nodes

EMQX version

```console $ ./bin/emqx_ctl broker sysdescr : EMQX version : 5.1.3 datetime : 2023-08-22T02:22:39.195573362+00:00 uptime : 13 seconds ``` ```console $ docker version Client: Version: 24.0.4 API version: 1.43 Go version: go1.20.5 Git commit: 3713ee1 Built: Fri Jul 7 14:49:50 2023 OS/Arch: linux/amd64 Context: default Server: Docker Engine - Community Engine: Version: 24.0.4 API version: 1.43 (minimum version 1.12) Go version: go1.20.5 Git commit: 4ffc614 Built: Fri Jul 7 14:51:12 2023 OS/Arch: linux/amd64 Experimental: true containerd: Version: v1.7.1 GitCommit: 1677a17964311325ed1c31e2c0a3589ce6d5c30d runc: Version: 1.1.7 GitCommit: v1.1.7-0-g860f061 docker-init: Version: 0.19.0 GitCommit: de40ad0 ```

OS version

```console # On Linux: $ cat /etc/os-release NAME="openEuler" VERSION="22.03 (LTS-SP1)" ID="openEuler" VERSION_ID="22.03" PRETTY_NAME="openEuler 22.03 (LTS-SP1)" ANSI_COLOR="0;31" $ uname -a # Linux docker1 5.10.0-136.40.0.117.oe2203sp1.x86_64 #1 SMP Wed Jul 12 14:29:52 CST 2023 x86_64 x86_64 x86_64 GNU/Linux ```

Log files

I don't have node_dump files, just docker logs

```console $ docker logs emqx hostname: Name or service not known EMQX_RPC__PORT_DISCOVERY [rpc.port_discovery]: manual EMQX_NODE__NAME [node.name]: emqx@ Kernel pid terminated (application_controller) ({application_start_failure,kernel,{{shutdown,{failed_to_start_child,net_sup,{shutdown,{failed_to_start_child,net_kernel,{'EXIT',nodistribution}}}}},{kernel,start,[normal,[]]}}}) {"Kernel pid terminated",application_controller,"{application_start_failure,kernel,{{shutdown,{failed_to_start_child,net_sup,{shutdown,{failed_to_start_child,net_kernel,{'EXIT',nodistribution}}}}},{kernel,start,[normal,[]]}}}"} ```
GuanTu commented 1 year ago

I found a solution here, but I still feel that if emqx.conf is mounted, it should not be regenerated into EMQX_NODE_NAME in docker-entrypoint.sh

GuanTu commented 1 year ago

10227