Docker image for Mosquitto. A lightweight MQTT broker for Raspberry Pi based on Arm Alpine Linux. Inspired by https://github.com/toke/docker-mosquitto
docker run -ti -p 1883:1883 -p 9001:9001 raymondmm/rpi-mosquitto
Exposes Port 1883 (MQTT) 9001 (Websocket MQTT)
Alternatively you can use a volume to make the changes persistent and change the configuration.
mkdir -p /srv/mosquitto/config/
mkdir -p /srv/mosquitto/data/
mkdir -p /srv/mosquitto/log/
# place your mosquitto.conf in /srv/mosquitto/config/
# NOTE: You have to change the permissions of the directories
# to allow the user to read/write to data and log and read from
# config directory
# For TESTING purposes you can use chmod -R 777 /srv/mosquitto/*
# Better use "-u" with a valid user id on your docker host
# Copy the files from the config directory of this project
# into /src/mosquitto/config. Change them as needed for your
# particular needs.
docker run -ti -p 1883:1883 -p 9001:9001 \
-v /srv/mosquitto:/mosquitto \
--name mosquitto raymondmm/mosquitto
Volumes: /mosquitto
Using Docker Volumes for persistence.
Create a named volume:
docker volume create --name mosquitto_data
Now it can be attached to docker by using -v mosquitto_data:/mosquitto
in the
Example above. Be aware that the permissions within the volumes
are most likely too restrictive.
Bind host /etc/localtime and /etc/timezone with the container too sync time and time zone:
docker volume create ... -v /etc/localtime:/etc/localtime:ro -v /etc/timezone:/etc/TZ:ro ...