本文を読み飛ばす

ARM SBC: install mqtt server with rootless podman

install MQTT server to SBC.

  • at this time, this MQTT server does not encrypt the communications. we need the TLS encryption for it.

make the configuration file::

cat >> mqtt.conf <<EOF
allow_anonymous false
listener 1883
listener 9001
protocol websockets
persistence true
password_file        /srv/mqtt/mqtt.pwfile
persistence_file     mqtt.db
persistence_location /srv/mqtt/data/

user root  # for podman rootless
EOF

points:
- persistence_file is the relative path from `persistence_location`
- a rootless podman needs `root user` as the running user,
    containers `mqtt` user does not have any permissions to mounted points.

create the container file::

```bash
mkdir app.mqtt; cd app.mqtt
cat > Containerfile <<EOF
FROM debian:12.11-slim

RUN apt update -y
RUN apt install -y mosquitte

RUN mkdir -p /srv/mqtt
RUN mosquitte_passwd -c -b /root/mqtt.pwfile admin ??????
RUN mosquitte_passwd    -b /root/mqtt.pwfile sensor1 ?????
RUN mosquitte_passwd    -b /root/mqtt.pwfile sensor2 ?????
RUN mosquitte_passwd    -b /root/mqtt.pwfile viewer  ?????

COPY mqtt.conf /srv/mqtt/mqtt.conf
CMD ["mosquitte", "-c", "/srv/mqtt/mqtt.conf"]
EOF

build the container::

podman build -t mqtt-server

up the container::

ext=/mnt/external/mqtt
podman run -v /srv/mqtt/data:$ext/data \
           -v /srv/mqtt/log:$ext/log \
           -p 1883 -p 9001 \
           -d mqtt-server

コメント

Comments powered by Disqus
宣伝: