码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • docker-compose安装mqtt


    docke和docker-compose环境自己解决

    一、新建文件夹mqtt和文件内部文件

    、

    1、编写docker-compose.yml文件 

    1. version: "3"
    2. services:
    3. mqtt:
    4. image: eclipse-mosquitto:2
    5. container_name: mqtt
    6. privileged: true
    7. ports:
    8. - 1883:1883
    9. - 9001:9001
    10. volumes:
    11. - ./config:/mosquitto/config
    12. - ./data:/mosquitto/data
    13. - ./log:/mosquitto/log

    2、config文件新建mosquitto.conf

    1. persistence true
    2. listener 1883
    3. persistence_location /mosquitto/data
    4. log_dest file /mosquitto/log/mosquitto.log
    5. # 关闭匿名模式
    6. #allow_anonymous true
    7. # 指定密码文件
    8. #password_file /mosquitto/config/pwfile.conf

    二、启动

    1. [mqtt]$ docker-compose up -d
    2. Creating network "mqtt_default" with the default driver
    3. Pulling mqtt (eclipse-mosquitto:2)...
    4. 2: Pulling from library/eclipse-mosquitto
    5. 213ec9aee27d: Pull complete
    6. c38859dc10af: Pull complete
    7. 20f8f1ac2856: Pull complete
    8. Digest: sha256:dbb267884bada100906702758cc2cbf334047f2837a52ae57ff272ea1ef6a99e
    9. Status: Downloaded newer image for eclipse-mosquitto:2
    10. Creating mqtt ... done

    三、设置密码

    进入容器内部
     docker exec -it mqtt sh
     
     生成文件 创建密码
    touch /mosquitto/config/pwfile.conf
    chmod -R 755 /mosquitto/config/pwfile.conf
    # 使用mosquitto_passwd命令创建用户,admin是用户名,admin123是密码
    mosquitto_passwd -b /mosquitto/config/pwfile.conf admin admin_23
    退出 
    exit 或者 Ctrl + D

    1. [mqtt]$ docker exec -it mqtt bash
    2. OCI runtime exec failed: exec failed: container_linux.go:367: starting container process caused: exec: "bash": executable file not found in $PATH: unknown
    3. [tly@sdmkdev1 mqtt]$ docker exec -it mqtt sh
    4. / # touch /mosquitto/config/pwfile.conf
    5. / # chmod -R 755 /mosquitto/config/pwfile.conf
    6. / # mosquitto_passwd -b /mosquitto/config/pwfile.conf admin admin123
    7. / # exit

    四、重启

    1. [mqtt]$ docker-compose restart
    2. Restarting mqtt ... done

    五、MQTTX客户端连接

    免费下载、试用 EMQ 产品

     

     

     

  • 相关阅读:
    C语言实现利用条件运算符的嵌套来完成此题:学习成绩>=90分的同学用A表示,60-89分之间的用B表示,60分以下的用C表示
    Vue中如何进行自定义图表与可视化图形设计
    【C++】内联函数&&auto关键字&&基于范围的for循环&&指针空值nullptr
    java框架-Spring-扩展原理
    35张图,直观理解Stable Diffusion
    猿创征文|瑞吉外卖——管理端_套餐管理
    SpringBoot集成Redis业务功能 02、定时任务+Redis删除特定前缀key的优雅实现
    Elasticvue - 用于浏览器的免费开源 Elasticsearch GUI
    使用nginx部署多个前端项目
    js中如何判断一个对象是否为空对象?
  • 原文地址:https://blog.csdn.net/xiaohanshasha/article/details/127666240
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号