Mosquitto - An Open Source MQTT v3.1/v3.1.1 Broker
100K+
Dockerfile linkslatest, 1, 1.4, 1.4.10 (Dockerfile)
1.4.8 (Dockerfile)
This repository holds a build definition and supporting files for building a Docker image to run Mosquitto.
It is published as automated build machine-data/mosquitto on Docker Hub.
Mosquitto is an open source (EPL/EDL licensed) message broker that implements the MQTT protocol versions 3.1 and 3.1.1. MQTT 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 like the Arduino.
Not quite:
/data - ready-to mount.Start Mosquitto and name the container mosquitto_test:
$ docker run -d \
--name mosquitto_test \
machine-data/mosquitto
Push a message to the broker:
$ docker run \
--rm -ti \
--link mosquitto_test \
machine-data/mosquitto \
mosquitto_pub \
-h mosquitto_test \
-t "mytopic/mypath" \
-m "message payload" \
-q 1 -r
Consume one message from the broker:
$ docker run \
--rm -ti \
--link mosquitto_test:mosquitto \
machine-data/mosquitto \
mosquitto_sub \
-h localhost \
-t "mytopic/mypath" \
-C 1
If Mosquitto ends, it will save the in-memory database to the /data directory, therefore it is recommended to bind mount a volume.
$ mkdir data
$ docker run -d \
--volume $(pwd)/data:/data \
--publish 1880:1880 \
machine-data/mosquitto
It is very easy to configure Mosquitto via environment variables. If no config file is present, the docker-entrypoint.sh script will create one based on sane defaults and environment variables.
MOSQUITTO_LOG_DEST: Change this from the default stdout if you like the logs being written to disk.
MOSQUITTO_PERSISTENCE: Save persistent message data to disk (true/false). Default: true
MOSQUITTO_PERSISTENCE_LOCATION: The directory where the in-memory database is being saved. This translates to persistence_location in mosquitto.conf. In most cases it makes sense to keep the /data/ default. NOTE: Must end in trailing slash.
The container is configured to start Mosquitto with /config/mosquitto.conf as config file.
If a config file (or the entire /config directory) is mounted (preferably read-only), the MOSQUITTO_ environment variables will be ignored:
$ curl -O https://raw.githubusercontent.com/eclipse/mosquitto/master/mosquitto.conf
$ sed -e "s#log_dest syslog#log_dest stdout#" \
-e "s#\#persistence false#persistence true#" \
-e "s#\#persistence_location#persistence_location /data/#" \
$ docker run -d \
-v $(pwd)/mosquitto.conf:/config/mosquitto.conf:ro \
-p 1883:1883 machine-data/mosquitto
/data: Path where Mosquitto's in-memory database id being saved.1883: Port for the default listener
8883: Recommended port for MQTT over TLS, needs to be set manually
9001: Websocket listener port, needs to be set manually
Mosquitto was written by Roger Light [email protected] and is dual licensed under the Eclipse Public License 1.0 and the Eclipse Distribution License 1.0. Copyright (c) 2007, Eclipse Foundation, Inc. and its licensors.
docker-mosquitto is licensed under the Apache 2.0 license, was created by Jodok Batlogg. Copyright 2016-2017 Crate.io, Inc..
Thanks for considering contributing to docker-mosquitto! The easiest way to contribute is either by filing an issue on Github or to fork the repository to create a pull request.
If you have any questions don't hesitate to join us on Slack.
Content type
Image
Digest
Size
2.1 MB
Last updated
over 9 years ago
docker pull machinedata/mosquitto