This container image contains the Mosquitto MQTT broker and client tools installed from EPEL repositories.
The default configuration file is located at /etc/mosquitto/mosquitto.conf. You
can override the default configuration by mounting your own configuration file
at this location with -v option like this:
docker ... -v mosquitto.conf:/mosquitto/config/mosquitto.conf ...
The /mosquito/logs and /mosquito/data directories were added, and the
proper permissions were set for ease of modification. It’s similar to the Eclipse
Foundation Original image except for the standard configuration residing in the
/etc/mosquito/mosquito.conf instead of /mosquito/config/mosquitto.conf
mosquitto.conf file./etc/mosquitto/mosquitto.conf location:
docker ... -v mosquitto.conf:/etc/mosquitto/mosquitto.conf ...
mosquitto.conf file:
persistence true
persistence_location /mosquitto/data/
/mosquitto/data/ directory to the host filesystem:
docker ... -v mosquitto-data:/mosquitto/data ...
By default, mosquitto logs are captured/written to standard system logs (systemd
journal). You can change this behavior by adding the following line to the
mosquitto.conf file:
log_dest file DEST
You can use the previously mentioned /mosquitto/ directory to store logs. For example:
log_dest file /mosquitto/log/mosquitto.log
Packaged mosquitto also has access to /var/log/mosquitto directory so you can use it as well:
log_dest file /var/log/mosquitto/mosquitto.log
Note that only one log destination can be used at a time.
Then, you can start the container with the following option:
docker ... -v mosquitto-log:/mosquitto/log ...
or similar package default:
docker ... -v mosquitto-log:/var/log/mosquitto ...
To run a temporary container with default configuration, execute the following command:
docker run --rm --name el9-mosquitto -p 1883:1883 eurolinux/eurolinux-9-mosquitto
To run the container with custom configuration, logging and data persitency properly configured, execute the following command:
docker run --name el9-mosquitto -p 1883:1883 -v mosquitto.conf:/etc/mosquitto/mosquitto.conf -v DATA_PATH:/mosquitto/data -v LOG_PATH:/mosquitto/log eurolinux/eurolinux-9-mosquitto
Where mosquitto.conf is your custom configuration file, DATA_PATH is the
path to the directory where you want to store mosquitto data and, LOG_PATH is
the path to the directory where you want to store mosquitto logs.
Example custom configuration file:
persistence true
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto.log
# Log types = debug, error, warning, notice, information, none, subscribe, unsubscribe, websockets, all
log_type information
log_type notice
log_type subscribe
log_type unsubscribe
log_type warning
log_type error
Lastly by adding the -d option you can run the container in the background.
docker run -d --name el9-mosquitto ...
mosquitto with UID/GID 984:985mosquitto user. It will also not create these directories even if proper
permissions on parent directories are set. If you want to use directories
different from the one provided in this short guide, you must create them
manually and set proper permissions.9001 port, which requires additional
configuration to work properly (it's not mentioned in their image guide)./etc/mosquitto/mosquitto.conf.Content type
Image
Digest
sha256:cdac95aa1…
Size
93.1 MB
Last updated
over 2 years ago
docker pull eurolinux/eurolinux-9-mosquitto