MQTT: How to Install as a Docker Container

MQTT: How to Install as a Docker Container

MQTT… “It is a publish/subscribe, extremely simple and lightweight messaging protocol, designed for constrained devices and low-bandwidth, high-latency or unreliable networks…” (MQTT: FAQ) While there are many MQTT implementations I settled on Eclipse Mosquitto as an open source message broker. I’ll be using Docker built on top of Ubuntu Server 16.04.

Host System Set-Up:

First, create the MQTT configuration, data, and log directories on the host docker file system. For my purposes I use the /opt/containters/parent directory for organizational purposes. We will be running the Docker container using the ‘user1’ account. The the ‘user1’ account will need to own the Docker file system directories.

Docker Set-Up:

We will need to retrieve a copy of the Eclipse Mosquitto configuration file located in the container at /mosquitto/config/mosquitto.conf. To do this we will create a temporary container running Eclipse Mosquitto, copy out the mosquitto.conf from the container to the Docker host system, delete the temporary container, and finally edit the mouitto.conf to make it ready for a running Mosquitto container.