version: '3.1'
services:
emqx: # 服务名称(可修改)
image: emqx:5.0.26
container_name: emqx
network_mode: host # 多主机使用host模式
restart: always
user: root
environment:
- "EMQX_NODE_NAME=node@192.168.1.222"
- "EMQX_CLUSTER__DISCOVERY_STRATEGY=etcd"
- "EMQX_CLUSTER__ETCD__SERVER=http://192.168.1.221:2379"
- "EMQX_NODE__COOKIE=abc"
volumes:
- /etc/localtime:/etc/localtime
- /opt/soft/emqx/log:/opt/emqx/log
- /opt/soft/emqx/data:/opt/emqx/data
healthcheck:
test: [ "CMD", "/opt/emqx/bin/emqx_ctl", "status" ]
interval: 5s
timeout: 25s
retries: 5
这是在docker-compose.yaml的环境变量中使用etcd发现,emqx集群是可以搭建成功的。
但是如果将/etc挂载到容器中,集群搭建失败,etc的配置都是从容器内的etc目录复制到物理目录的,只有集群的配置改成了这样:
cluster {
discovery_strategy = etcd
etcd {
server = "http://192.168.1.221:2379"
prefix = emqcl
node_ttl = 1m
}
}
还有,关于安装部署的讲解过于简略。。。