-
Mosquitto提供Docker镜像,初次运行时我们需要拷贝出一些默认的配置文件,具体原因参照Docker Compose挂载目录的限制和解决办法
docker run -dit eclipse-mosquitto docker cp [container_id]:/mosquitto/data /....../mosquitto/ docker cp [container_id]:/mosquitto/log /....../mosquitto/ docker cp [container_id]:/mosquitto/config /....../mosquitto/
-
接下来配合Docker Compose方法一套带走
version: '3.6'services:mosquitto:tty: trueimage: eclipse-mosquittoports: # 冒号后面的端口建议不修改- "9001:9001" - "1883:1883"volumes:- ./data:/mosquitto/data- ./log:/mosquitto/log- ./config:/mosquitto/config
-
在
./config/mosquitto.conf
中有一些关键的配置port 9001 protocol websockets listener 1883
这样会在
1883
端口监听http消息,在9001
端口监听ws消息
MINE MIND系列将在我的GitHub上实时更新,同时精选部分汇总于CSDN专栏
GitHub仓库:https://github.com/IcyLeaves/MINE-MIND
CSDN专栏:https://blog.csdn.net/qq_37398834/category_10975647.html