emqx通过Docker容器化部署流程
1.创建持久化挂载目录
mkdir -p /home/emqx/etc ------挂载emqx的配置文件目录
mkdir -p /home/emqx/data ------挂载emqx的存储目录
mkdir -p /home/emqx/log ------挂载emqx的日志目录
[root@ home]# mkdir -p /home/emqx/etc
[root@ home]# mkdir -p /home/emqx/data
[root@ home]# mkdir -p /home/emqx/log
2.启动临时容器
[root@ home]# docker run -d --name emqx -p 1883:1883 -p 8083:8083 -p 8084:8084 -p 8883:8883 -p 18083:18083 emqx/emqx:latest
Trying to pull repository docker.io/emqx/emqx ...
latest: Pulling from docker.io/emqx/emqx
8572bc8fb8a3: Pull complete
2515d7555202: Pull complete
5c87fdd888ef: Pull complete
c227b2804671: Pull complete
f3c4e6b224c6: Pull complete
d1d9200332e3: Pull complete
77131c6e337c: Pull complete
Digest: sha256:d88ff149d60584cd1dab334761d8b971d318e4417e488bc6201e95719f339b58
Status: Downloaded newer image for docker.io/emqx/emqx:latest
3.复制emqx容器文件,放到指定路径,并赋予权限
[root@ home]# docker cp emqx:/opt/emqx/etc /home/emqx/
[root@ home]# docker cp emqx:/opt/emqx/data /home/emqx/
[root@ home]# docker cp emqx:/opt/emqx/log /home/emqx/
[root@ home]# chmod -R 777 /home/emqx/{data,etc,log}
4.销毁临时容器
[root@ emqx]# docker stop emqx
emqx
[root@ emqx]# docker rm emqx
emqx
5.正式启动容器
docker run -d --name emqx --restart always --privileged=true -p 1883:1883 -p 8083:8083 -p 8084:8084 -p 8883:8883 -p 18083:18083 -v /home/emqx/etc:/opt/emqx/etc -v /home/emqx/data:/opt/emqx/data -v /home/emqx/log:/opt/emqx/log emqx/emqx:latest
978ae7cbf1b82a48e1a51aaf3dc429642744a0a7a93117634ed67781d2b0ac46
PS:默认用户名密码为 admin/public
如果需要修改密码可以执行下面命令
docker exec -it emqx bash -c “./bin/emqx_ctl admins passwd admin 123456”
6.测试验证
在浏览器页面访问地址:http://IP:18083
至此搭建成功!
-----编辑者:梦想的边缘