HUB
Sign inSign up
eurolinux-9-mosquitto logo

eurolinux/eurolinux-9-mosquitto

By eurolinux

•Updated over 2 years ago

Image
0

2.4K

eurolinux/eurolinux-9-mosquitto repository overview

⁠Mosquitto on Enterprise Linux 9

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

⁠Using custom configuration

  1. Set your custom configuration file in the mosquitto.conf file.
  2. Mount your configuration file to the /etc/mosquitto/mosquitto.conf location:
    docker ... -v mosquitto.conf:/etc/mosquitto/mosquitto.conf ...
    

⁠Data persitency

  1. Add the proper config lines into the mosquitto.conf file:
    persistence true
    persistence_location /mosquitto/data/
    
  2. Mount the /mosquitto/data/ directory to the host filesystem:
    docker ... -v mosquitto-data:/mosquitto/data ...
    

⁠Logging

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 ...

⁠Running the container

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 ...

⁠Extra notes

  1. Mosquitto is running as a non-root user mosquitto with UID/GID 984:985
  2. Mosquitto will not start if log or data directories are not writable by the mosquitto 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.
  3. The Eclipse Foundation Original image is available at Docker Hub⁠. The guide for their image recommends adding the useless 9001 port, which requires additional configuration to work properly (it's not mentioned in their image guide).
  4. Mosquitto configuration file in pristine form is always available in container at /etc/mosquitto/mosquitto.conf.

Tag summary

Content type

Image

Digest

sha256:cdac95aa1…

Size

93.1 MB

Last updated

over 2 years ago

docker pull eurolinux/eurolinux-9-mosquitto