docker-compose EMQX安装

2020/7/2

构建环境:docker、docker-compose

# 配置文件

vim /docker/docker-compose.yml

version: "3.9"
services:
  emqx:
        image: emqx/emqx:v4.0.0
    container_name: emqx
    ports:
      - "1883:1883"
      - "8083:8083"
      - "8883:8883"
      - "8084:8084"
      - "18083:18083"
    environment:
      - EMQX_DASHBOARD__DEFAULT_USER__LOGIN=admin
      - EMQX_DASHBOARD__DEFAULT_USER__PASSWORD=123456
      - TZ=Asia/Shanghai
      - EMQX_ALLOW_ANONYMOUS=false
      - EMQX_LOADED_PLUGINS=emqx_dashboard,emqx_management,emqx_recon,emqx_retainer,emqx_rule_engine,emqx_auth_username
    volumes:
      - /etc/localtime:/etc/localtime
      - /docker/emqx/conf/acl.conf:/opt/emqx/etc/acl.conf
      - /docker/emqx/conf/emqx_auth_username.conf:/opt/emqx/etc/plugins/emqx_auth_username.conf
    restart: always
    deploy:
      resources:
        limits:
          memory: 600M

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

vim emqx_auth_username.conf

##--------------------------------------------------------------------
## Username Authentication Plugin
##--------------------------------------------------------------------

## Examples:
auth.user.1.username = admin
auth.user.1.password = public
auth.user.2.username = qwrt
auth.user.2.password = Qwrt-123
##auth.user.3.username = name~!@#$%^&*()_+
##auth.user.3.password = pwsswd~!@#$%^&*()_+


## Password hash.
##
## Value: plain | md5 | sha | sha256 
auth.user.password_hash = sha256

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

vim acl.conf

%%--------------------------------------------------------------------
%% [ACL](https://docs.emqx.io/broker/v3/en/config.html)
%%
%% -type(who() :: all | binary() |
%%                {ipaddr, esockd_access:cidr()} |
%%                {client, binary()} |
%%                {user, binary()}).
%%
%% -type(access() :: subscribe | publish | pubsub).
%%
%% -type(topic() :: binary()).
%%
%% -type(rule() :: {allow, all} |
%%                 {allow, who(), access(), list(topic())} |
%%                 {deny, all} |
%%                 {deny, who(), access(), list(topic())}).
%%--------------------------------------------------------------------




{allow, {user, "admin"}, pubsub, ["/test/#"]}.
{allow, {user, "qwrt"}, pubsub, ["/EMETER/#"]}.
{deny, all}.


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

# 运行

运行:docker-compose up -d
1
Last Updated: 2023/12/4 12:06:46