Git Product home page Git Product logo

docker-mosquitto's Introduction

Supported tags and respective Dockerfile links

Mosquitto on Docker

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.

What is Mosquitto?

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.

Yet another Mosquitto container?

Not quite:

  • Based on the official Alpine Linux image - super slim and lightweight.
  • No magic. Straight config that follows upstream. Simple and clean configuration via environment variables or config file.
  • Image follows Dockerfile best practices (dropping root privileges, PID1 for proper signalling, logging,...)
  • All user data under /data - ready-to mount.

Quickstart

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

Environment variables

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.

Configuration file

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

Volumes

  • /data: Path where Mosquitto's in-memory database id being saved.

Ports

  • 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

Legal

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..

Contributing

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.

docker-mosquitto's People

Contributors

jodok avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.