EMQTT Docker 容器
CentOS 7 基底的 EMQ MQTT Broker(emqttd v2.2.0)容器。適合單機開發或功能驗證;要跑叢集與自動擴展請看 EMQTT on Kubernetes。
Dockerfile
FROM centos:7
RUN yum -y install \
epel-release \
erlang \
wget \
zip unzip
RUN yum clean all
RUN wget http://emqtt.io/static/brokers/emqttd-centos7-v2.2.0.zip
RUN unzip emqttd-centos7-v2.2.0.zip -d .
COPY docker-entrypoint.sh /usr/local/bin/
RUN ln -s usr/local/bin/docker-entrypoint.sh /entrypoint.sh
ENTRYPOINT sh entrypoint.sh && bash
EMQ 是 Erlang 寫的,所以基底需要先裝 erlang(來自 EPEL)。
建置與執行
# 建置映像
docker build -t emqttd:2.2.0 .
# 啟動 Broker
docker run -d \
-p 1883:1883 \
-p 8083:8083 \
-p 18083:18083 \
--name emqttd emqttd:2.2.0
| Port | 用途 |
|---|---|
| 1883 | MQTT over TCP |
| 8083 | MQTT over WebSocket |
| 18083 | Dashboard(預設帳密 admin / public) |
驗證
# 訂閱
mosquitto_sub -h localhost -p 1883 -t 'test/#' -v
# 另一個終端發布
mosquitto_pub -h localhost -p 1883 -t 'test/hello' -m 'hello mqtt'
版本說明
emqttd v2.2.0 是舊版命名,專案後來改名為 EMQX,套件下載位置與設定檔格式都有變動。要用新版請參考 EMQX 官方文件。
← 回到 IoT 物聯網與訊息佇列