准备目录

mkdir mosquitto-config mosquitto-data mosquitto-log

编辑 docker-compose.yml 文件

version: '3.3'
services:
    eclipse-mosquitto:
        ports:
            - '1883:1883'
            #- '9001:9001'
        volumes:
            - './mosquitto-config/mosquitto.conf:/mosquitto/config/mosquitto.conf'
            - './mosquitto-data:/mosquitto/data'
            - './mosquitto-log:/mosquitto/log'
        image: eclipse-mosquitto

设置开机自动启动

podman-compose systemd -a register
systemctl --user enable --now 'podman-compose@mosquitto'
systemctl --user status 'podman-compose@mosquitto'

打开防火墙

sudo firewall-cmd --zone=internal --new-service=mosquitto --permanent
sudo firewall-cmd --zone=internal --service=mosquitto --add-port=1883/tcp --permanent
sudo firewall-cmd --zone=internal --add-service=mosquitto --permanent
sudo firewall-cmd --reload

发表评论