其他分享
首页 > 其他分享> > docker安装mqtt服务

docker安装mqtt服务

作者:互联网

 

#创建数据

root@xie-virtual-machine:/home/mosquitto# cat config/mosquitto.conf 
persistence true
persistence_location /mosquitto/data
log_dest file /mosquitto/log/mosquitto.log
allow_anonymous true
listener 1883

 

docker search mqtt
docker pull eclipse-mosquitto 

#启动容器
docker run -d --name=mosquitto --privileged -p 1883:1883 -p 9001:9001 -v /home/mosquitto/config/mosquitto.conf:/mosquitto/config/mosquitto.conf -v /home/mosquitto/data:/mosquitto/data -v /home/mosquitto/log:/mosquitto/log eclipse-mosquitto:latest

root@xie-virtual-machine:/home/mosquitto# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4e0234cd7933 eclipse-mosquitto:latest "/docker-entrypoint.…" 28 minutes ago Up 8 minutes 0.0.0.0:1883->1883/tcp, :::1883->1883/tcp, 0.0.0.0:9001->9001/tcp, :::9001->9001/tcp mosquitto


#进入容器内部进行测试
docker exec -it 4e0234cd7933 sh

#本机订阅发布测试:

#订阅

mosquitto_sub -t test

#另开一个窗口进行发布

mosquitto_pub  -t test -m "hello"



标签:log,安装,mqtt,mosquitto,9001,home,docker,1883
来源: https://www.cnblogs.com/huangyuanni/p/15985718.html