Docker Mosquitto 不会加载配置

问题描述 投票:0回答:0

目标是在 docker 中运行一个 mosquitto 代理,它应该订阅同一网络中不同设备发布的主题。主机操作系统是 Centos(最小安装)。 不幸的是有两个问题

  1. Mosquitto 没有加载我在 docker-compose.yml 中提供的自定义 mosquitto.conf
  2. "Error: Address in use"
    – 即使主机或不同容器上没有运行其他 Mosquitto 服务。 (用
    netstat -tunlp
    docker ps -a
    检查)
1681677658: mosquitto version 2.0.15 starting
1681677658: Using default config.
1681677658: Starting in local only mode. Connections will only be possible from clients running on this machine.
1681677658: Create a configuration file which defines a listener to allow remote access.
1681677658: For more details see https://mosquitto.org/documentation/authentication-methods/
1681677658: Opening ipv4 listen socket on port 1883.
1681677658: Error: Address in use
1681677658: Opening ipv6 listen socket on port 1883.
1681677658: Error: Address not available

docker-compose.yml 和 mosquitto.conf:

---
version: '3.7'

services:
  mosquitto:
    image: eclipse-mosquitto
    container_name: mosquitto
    restart: always
    volumes:
      - /opt/mosquitto/config:/mosquitto/config
      - /opt/mosquitto/mosquitto/data:/mosquitto/data
      - /opt/mosquitto/mosquitto/log:/mosquitto/log
    ports:
      - 1883:1883
      - 9001:9001
persistence true
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto.log
listener 1883

## Authentication ##
allow_anonymous true

到目前为止我尝试了什么:

  • 设置用户/密码(
    mosquitto_passwd -c /mosquitto/config/password.txt mqttuser
    --> 编辑 mosquitto.conf(allow_anonymous false & password_file /mosquitto/config/password.txt)--> 重新启动容器)
  • 将 mosquitto/config/mosquitto.conf 放在 docker-compose 目录中,而不是 /opt 并相应地更新 docker-compose.yml
  • 尝试了不同的文件夹路径,例如蚊子/conf/mosquitto.conf
  • docker-compose.yml 中的不同路径,例如蚊子/config/mosquitto.conf:/mosquitto/config/mosquitto.conf
  • 检查我的 libseccomp 是否过时(2.5.2-2.el9),因为有人有类似的问题link
  • 每次尝试后,我都会移除容器并从头开始。重启机器。

我希望加载正确的配置后“正在使用的地址”错误将得到解决?如果有人能指出正确的方向,我将非常感激。我是不是忽略了什么?

docker docker-compose mqtt mosquitto
© www.soinside.com 2019 - 2024. All rights reserved.