Skip to content

Latest commit

 

History

History
61 lines (43 loc) · 2.37 KB

README.md

File metadata and controls

61 lines (43 loc) · 2.37 KB

DOCKER COMPOSE - Eclipse/Mosquitto MQTT Broker

Summary

This is a Docker Compose project that will build and run a Mosquitto MQTT broker with TLS and username/password authentication.

Dependencies

  • Docker must be installed on the host system.
  • The host must have internet access to build the initial image. (See "Offline Usage" below if you need to use this in an offline environment.)
  • Docker Build will use eclipse-mosquitto:2.0.15 from Docker Hub. Edit the Dockerfile to change the version if needed.
  • (Optional) If you plan to use the included TLS generation script, you'll also need Python 3.6 or later with openssl. These are only used when you run the TLS generation script and are not needed to otherwise build or run the container.

Usage

Before Starting

  1. Provide TLS certs in ./mosquitto/secrets. See ./mosquitto/secrets/README - secrets.md for details.
  2. Provide a password file in ./mosquitto/secrets. See ./mosquitto/secrets/README - secrets.md for details.

CONTAINER START

Start the container with the following command:

$ docker compose up -d
  • On first "up" the image will build from the Dockerfile. This might take a few minutes. See below for "offline usage" if you need to use this in an offline environment.

CONTAINER STOP

To stop the container, use:

$ docker compose down

Offline Usage

If you need to use this container on a server that does not have Internet, you can:

  • Build the image on a connected server first. From the root director of this repo:
    $ docker compose build
  • Export the docker image to a file. From the root directory of this repo:
    $ docker save -o ./exported-eclipse-mosquitto.docker eclipse-mosquitto 
  • Move the all the files in this repo, including the exported docker image, using any offline method (usb drive, etc.)
  • Load the image on the offline server. On the offline server, from the root directory of this project:
    $ docker load -i ./exported-eclipse-mosquitto.docker
  • Start the container on the offline server as described above.

Clients

After the mosquitto broker is up, connect to it with any mosquitto client.

I recommend the very fine MQTT Explorer: https://mqtt-explorer.com/.

Note: If you used self-signed certs, remember to pass the CA cert to your client so that it may do certificate validation for you.