Installing Eclipse Mosquitto in a Container

Eclipse Mosquitto is an open source (EPL/EDL licensed) message broker that implements the MQTT protocol versions 5.0, 3.1.1 and 3.1. Mosquitto is lightweight and is suitable for use on all devices from low power single board computers to full servers.

The MQTT protocol provides a lightweight method of carrying out messaging using a publish/subscribe model. This makes it suitable for Internet of Things messaging such as with low power sensors or mobile devices such as phones, embedded computers or microcontrollers.

Running Mosquitto is easiest in a Docker container. This is really easy to set up.

docker pull eclipse-mosquitto

Pull the container from the Docker Repository

sudo docker run -d -p 1883:1883 -p 9001:9001 -v mosquitto.conf:/home/ubuntu/mosquitto/config/mosquitto.conf -v /mosquitto/data -v /mosquitto/log eclipse-mosquitto

Start Mosquitto.

The default port for Mosquitto is 1883. Also ensure that the volumes are mapped to a local folder on the host to preserve the configuration.