Mosquitto is a message broker that implements the MQTT protocol versions 3.1 and 3.1.1 (and in this Docker image, WebSocket.) Mosquitto is lightweight and is suitable for use on all devices from low power single board computers to full servers.
Mosquitto with Authentication is a Docker image that bundles the Mosquitto server, popular authentication plugin, mosquitto-auth-plug, and Libwebsockets for WebSockets support, for ease-of-use.
Pull from Docker Hub
docker pull ltgiv/docker-mosquitto:source
Mosquitto from official PPA (sometimes slightly older version)
docker pull ltgiv/docker-mosquitto:ppa
It's easy to build a local image directly from GitHub:
git clone https://github.com/LTGIV/docker-mosquitto.git \
&& \
cd ./docker-mosquitto \
;
docker build \
--tag ltgiv/docker-mosquitto:source \
--file Dockerfile-source \
. \
;
Installed from official PPA (sometimes slightly older version)
docker build \
--tag ltgiv/docker-mosquitto:ppa \
--file Dockerfile-ppa \
. \
;
Using Docker Compose, as described in Tying MQTT, WebSockets, and Nginx together with Docker:
---
version: '3'
################################################################################
networks:
messaging:
driver: bridge
################################################################################
services:
################################################################################
web:
container_name: nginx
image: nginx:latest
restart: always
# Public access
ports:
- 80:80 # HTTP
- 443:443 # HTTPS
# Peer networks
networks:
- messaging
volumes:
- /root/srv/letsencrypt/etc/:/etc/letsencrypt/:ro
- /root/srv/nginx/etc/:/etc/nginx/:ro
- /root/srv/nginx/log/:/var/log/nginx/
- /root/srv/sites/:/sites/:ro
- /root/srv/sites/default/:/usr/share/nginx/html/:ro
################################################################################
message:
container_name: mosquitto
restart: always
# Change to ppa, source, or latest (latest is synonymous for source)
image: ltgiv/docker-mosquitto:ppa
# image: ltgiv/docker-mosquitto:source
# image: ltgiv/docker-mosquitto:latest
# Public access
ports:
- 127.0.0.1:1883:1883 # MQTT - Insecure
- 8883:8883 # MQTT - Secure
- 127.0.0.1:9001:9001 # WebSockets - Insecure
- 127.0.0.1:9002:9002 # WebSockets - Secure
# Peer containers (e.g. mosquitto_pub, mosquitto_sub, and Nginx)
expose:
- 1883/tcp # MQTT - Insecure
- 9001/tcp # WebSockets - Insecure
# Peer networks
networks:
- messaging
volumes:
- /root/srv/letsencrypt/etc/:/etc/letsencrypt/:ro
- /root/srv/mosquitto/etc/:/etc/mosquitto/:ro
- /root/srv/mosquitto/lib/:/var/lib/mosquitto/
- /root/srv/mosquitto/log/:/var/log/mosquitto/
################################################################################
- Louis T. Getterman IV
- Have an improvement? Your name goes here!
Written with StackEdit.