前言
本文的原文连接是: https://blog.csdn.net/freewebsys/article/details/87606981
未经博主允许不得转载。
博主地址是:http://blog.csdn.net/freewebsys
1,关于 mosquitto
这个是一个 eclipse 项目下面的。
https://mosquitto.org/
github项目地址:
https://github.com/eclipse/mosquitto
docker hub 项目地址:
https://hub.docker.com/_/eclipse-mosquitto
dockerfile :
https://github.com/eclipse/mosquitto/blob/ff36baa49e37eb27d998314d46f01ddd914fdd65/docker/1.5/Dockerfile
非常的小呢。只有 不到 5MB 呢,c++开发就是省资源呢。
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
eclipse-mosquitto latest 50373582ca5c 9 days ago 4.78MB
2,使用
使用docker file 启动:
docker run --name mosquitto -itd -p 1883:1883 -p 9001:9001 eclipse-mosquitto:latest
因为系统是 alpine 打包的。所以没有 bash 使用 sh进行登录。
docker exec -it mosquitto sh
/ # ls
bin etc media proc sbin tmp
dev home mnt root srv usr
docker-entrypoint.sh lib mosquitto run sys var
/ # ps -ef
PID USER TIME COMMAND
1 mosquitt 0:00 /usr/sbin/mosquitto -c /mosquitto/config/mosquitto.conf
11 root 0:00 sh
18 root 0:00 ps -ef
然后使用 mqttbox 进行测试。
查看 docker 的log:发现新的连接connected 到服务器上了。
$ docker logs 51
1550463946: mosquitto version 1.5.6 starting
1550463946: Config loaded from /mosquitto/config/mosquitto.conf.
1550463946: Opening ipv4 listen socket on port 1883.
1550463946: Opening ipv6 listen socket on port 1883.
1550463981: New connection from 172.17.0.1 on port 1883.
1550463981: New client connected from 172.17.0.1 as 0a2da66f-5ead-44df-b5bf-646fa6b3529f1550463981657 (c1, k10).
3,总结
mosquitto 项目是 用 c++ 写的项目。
配置文件:
https://github.com/eclipse/mosquitto/blob/master/mosquitto.conf
c++写的非常的小。编译之后加上 alpine 也还是非常的小。
编译dockerfile 都写的详细了。
本文的原文连接是:
https://blog.csdn.net/freewebsys/article/details/87606981