1、查找镜像
docker search mosquitto
2、拉镜像
docker pull eclipse-mosquitto
3、创建目录
mkdir -p /mosquitto/config mkdir -p /mosquitto/data mkdir -p /mosquitto/log
4、初始化配置文件
vi /mosquitto/config/mosquitto.conf
persistence true persistence_location /mosquitto/data log_dest file /mosquitto/log/mosquitto.log listener 1883 allow_anonymous true
5、授权文件
chmod -R 755 /mosquitto chmode -R 777 /mosquitto/log
6、启动镜像
docker run -it --name=mosquitto --privileged -p 1883:1883 -p 9001:9001 -v /mosquitto/config/mosquitto.conf:/mosquitto/config/mosquitto.conf -v /mosquitto/data:/mosquitto/data -v /mosquitto/log:/mosquitto/log -d eclipse-mosquitto
7、连接测试成功