Portainer Templates logo

Portainer Templates

Eclipse Mosquitto MQTT Eclipse Mosquitto MQTT

Container

OtherTools

Eclipse Mosquitto is an open source message broker that implements the MQTT protocol versions 5.0, 3.1.1 and 3.1. Mosquitto is lightweight and is suitable for use on all devices from low power single board computers to full servers. Have a look on https://mosquitto.org/man/mosquittopasswd-1.html

Image details

Pulls: 677.0M
Architecture: amd64, arm64, arm/v6, 386, ppc64le, s390x, arm64/v8
Image size: 10 MB
Latest: 2.1.2-alpine
User: library
Created: Dec 13, 2016
Updated: 1 month ago
Status: active

Configuration

Type
Container
Platform
linux
Image
eclipse-mosquitto:latest
Ports
1883:1883/tcp9001:9001/tcp
Volumes
/mosquitto/config : /portainer/Files/AppData/Config/eclipse-mosquitto/config/mosquitto/data : /portainer/Files/AppData/Config/eclipse-mosquitto/data/mosquitto/log : /portainer/Files/AppData/Config/eclipse-mosquitto/log
Restart
unless-stopped

Template by novaspirit

Notes

Template created by Pi-Hosted Series
Check our Github page: https://github.com/pi-hosted/pi-hosted

Official Webpage: https://mosquitto.org/
Official Docker Documentation: https://mosquitto.org/

Pre-installation script must be RAN before you install: wget -qO- https://raw.githubusercontent.com/pi-hosted/pi-hosted/master/tools/install_mosquitto.sh | bash



Standalone Install

Select an install method, to see config/commands for deploying Eclipse Mosquitto MQTT

Installation method

Install on Portainer

Import all app templates into your Portainer instance, for easy 1-click deploys

  1. Ensure both Docker and Portainer are installed, and up-to-date
  2. Log into your Portainer web UI
  3. Under Settings → App Templates, paste the below URL
  4. Head to Home → App Templates, and the list of apps will show up
  5. Select Eclipse Mosquitto MQTT, fill in any config options, and hit Deploy

Template Import URL

https://raw.githubusercontent.com/Lissy93/portainer-templates/main/templates.json
Show Me demo

More install options in our documentation.

Quick reference

  • Maintained by:
[the Eclipse Foundation](https://github.com/eclipse/mosquitto)
  • Where to get help:
[the Docker Community Slack](https://dockr.ly/comm-slack), [Server Fault](https://serverfault.com/help/on-topic), [Unix & Linux](https://unix.stackexchange.com/help/on-topic), or [Stack Overflow](https://stackoverflow.com/help/on-topic)

Supported tags and respective Dockerfile links



Quick reference (cont.)

  • Where to file issues:
[https://github.com/eclipse/mosquitto/issues](https://github.com/eclipse/mosquitto/issues?q=)
[`amd64`](https://hub.docker.com/r/amd64/eclipse-mosquitto/), [`arm32v6`](https://hub.docker.com/r/arm32v6/eclipse-mosquitto/), [`arm64v8`](https://hub.docker.com/r/arm64v8/eclipse-mosquitto/), [`i386`](https://hub.docker.com/r/i386/eclipse-mosquitto/), [`ppc64le`](https://hub.docker.com/r/ppc64le/eclipse-mosquitto/), [`s390x`](https://hub.docker.com/r/s390x/eclipse-mosquitto/)
  • Published image artifact details:
[repo-info repo's `repos/eclipse-mosquitto/` directory](https://github.com/docker-library/repo-info/blob/master/repos/eclipse-mosquitto) ([history](https://github.com/docker-library/repo-info/commits/master/repos/eclipse-mosquitto))  
(image metadata, transfer size, etc)
  • Image updates:
[official-images repo's `library/eclipse-mosquitto` label](https://github.com/docker-library/official-images/issues?q=label%3Alibrary%2Feclipse-mosquitto)  
[official-images repo's `library/eclipse-mosquitto` file](https://github.com/docker-library/official-images/blob/master/library/eclipse-mosquitto) ([history](https://github.com/docker-library/official-images/commits/master/library/eclipse-mosquitto))
  • Source of this description:
[docs repo's `eclipse-mosquitto/` directory](https://github.com/docker-library/docs/tree/master/eclipse-mosquitto) ([history](https://github.com/docker-library/docs/commits/master/eclipse-mosquitto))

What is Eclipse Mosquitto?

Eclipse Mosquitto is an open source implementation of a server for versions 5, 3.1.1, and 3.1 of the MQTT protocol. Main homepage: http://mosquitto.org/
logo

Eclipse Mosquitto and Cedalo

Cedalo provides commercial support, enterprise MQTT products, professional services and training for Eclipse Mosquitto.

How to use this image

Directories

Three directories have been created in the image to be used for configuration, persistent storage and logs.
/mosquitto/config
/mosquitto/data
/mosquitto/log
It is suggested to mirror this structure for your local configuration.

Configuration

When running the image, the default configuration values are used. To use a custom configuration file, create your mosquitto.conf in $PWD/mosquitto/config/mosquitto.conf, then mount the config directory to /mosquitto/config.
$ docker run -it -p 1883:1883 -v "$PWD/mosquitto/config:/mosquitto/config" eclipse-mosquitto

Configuration can be changed to:
  • persist data to /mosquitto/data
  • log to /mosquitto/log/mosquitto.log

i.e. add the following to mosquitto.conf:
persistence true
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto.log
Note: If a volume is used, the data will persist between containers.

Run

Run a container using the new image:
$ docker run -it -p 1883:1883 -v "$PWD/mosquitto/config:/mosquitto/config" -v /mosquitto/data -v /mosquitto/log eclipse-mosquitto

or:
$ docker run -it -p 1883:1883 -v "$PWD/mosquitto/config:/mosquitto/config" -v "$PWD/mosquitto/data:/mosquitto/data" -v "$PWD/mosquitto/log:/mosquitto/log" eclipse-mosquitto

Note: if the mosquitto configuration (mosquitto.conf) was modified to use non-default ports, the docker run command will need to be updated to expose the ports that have been configured.
For example, if you use port 1883 and port 8080:
$ docker run -it -p 1883:1883 -p 8080:8080 -v "$PWD/mosquitto/config:/mosquitto/config" eclipse-mosquitto

Image tags

The supported-tags list at the top of this page is authoritative. Official eclipse-mosquitto images are Alpine-based. Tag naming does not follow a generic "plain version" vs "version-alpine" split:
  • 2.1.x: tags such as 2.1.2-alpine, 2.1-alpine, alpine, 2, and latest all refer to the current Alpine 2.1 image. There is no separate non-Alpine 2.1 tag.
  • 2.0.x (OpenSSL): tags such as 2.0.22, 2.0.22-openssl, 2.0, 2.0-openssl, 2-openssl, and openssl refer to the Alpine 2.0 OpenSSL image (TLS-PSK and related OpenSSL features). Prefer an explicit 2.0* / *-openssl tag if you need this line; do not assume openssl alone means "latest Mosquitto".
  • 1.6.x (OpenSSL): tags such as 1.6.15-openssl and 1.6-openssl refer to the Alpine 1.6 OpenSSL image.

If you are unsure which tag to use for current Mosquitto, prefer latest or a pinned 2.1*-alpine tag from the supported-tags list.

License

Eclipse Mosquitto is released under the EPL/EDL
As with all Docker images, these likely also contain other software which may be under other licenses (such as Bash, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained).
Some additional license information which was able to be auto-detected might be found in the repo-info repository's eclipse-mosquitto/ directory.
As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within.

Serve Eclipse Mosquitto MQTT on your own domain behind Caddy, Nginx or Traefik. Fill in your domain and copy the result. It's a starting point, some apps need their own base URL or extra headers set too.

Proxying eclipse-mosquitto-mqtt.example.com to http://eclipse-mosquitto:1883

Add this to your Caddyfile

eclipse-mosquitto-mqtt.example.com {
	reverse_proxy http://eclipse-mosquitto:1883
}

Check the logs first

Nine times out of ten the logs tell you exactly what went wrong.

  • In Portainer, go to Containers, click the container, then Logs. Or run docker logs eclipse-mosquitto
  • Exit codes help too: 137 means killed, usually out of memory. 126 or 127 means the command inside the image is broken.

Port already in use

If deployment fails with "Bind for 0.0.0.0:1883 failed: port is already allocated", something else on your server is using that port.

  • Find what's using it: sudo ss -tlnp | grep :1883
  • Stop the other service, or pick a different host port. In 1883:1883 only the left number is yours to change, the right one belongs to the app.

Running but the page won't load

The container is up but nothing appears in your browser.

  • Use your server's real IP: http://your-server-ip:1883. The 0.0.0.0 link Portainer shows isn't a real address.
  • Give it a minute after first deploy, eclipse-mosquitto can take a while to initialise.
  • Make sure your firewall allows the port, e.g. sudo ufw allow 1883

Permission denied on volumes

If the logs show "permission denied", the app can't write to its data folder on the host.

  • Fix the ownership: sudo chown -R 1000:1000 /portainer/Files/AppData/Config/eclipse-mosquitto/config (and the same for the other mapped folders)

Image won't pull

Test the pull directly on the host: docker pull eclipse-mosquitto:latest

  • "manifest unknown" means the tag no longer exists. This template uses latest, so try pinning a specific version instead.
  • "toomanyrequests" is the Docker Hub rate limit. Log in with docker login to raise it.
  • "no space left on device" means a full disk. Reclaim space with docker system prune

"exec format error"

This means the image was built for a different CPU architecture than your server.

  • This image supports: amd64, arm64, arm/v6, 386, ppc64le, s390x, arm64/v8
  • Check yours with uname -m: x86_64 is amd64, aarch64 is arm64. Raspberry Pi and other ARM boards are the usual culprits.

Container keeps restarting

The unless-stopped restart policy relaunches the app after every crash, so the real error can scroll past.

  • Check the logs right after a restart, the last few lines before it died are the useful ones.
  • Get the exit code with docker inspect eclipse-mosquitto --format '{{.State.ExitCode}}'
  • Still stuck? Redeploy once with the restart policy set to no so the failure stays visible.

Raise an issue

Found something which isn't working as it should? Here's how to report it.

A single container

Eclipse Mosquitto MQTT runs as one container, the simplest kind of app here. Just the one image to pull and nothing else wired up alongside it.

The app image

An image is the app packed up ready to go, everything Eclipse Mosquitto MQTT needs bundled into one download. This template pulls eclipse-mosquitto:latest, which Docker fetches once (about 10 MB) and then starts your own copy from.

Where the image comes from

Docker pulls its images from registries, public libraries of ready-built apps. Eclipse Mosquitto MQTT's comes from Docker Hub as one of its official, curated images.

Version tags

The bit after the colon in the image name is the version tag. Here it's latest, which always points at the newest build, so a redeploy can bump you to a newer release without you asking. Newest right now is 2.1.2-alpine. Pin a specific tag if you would rather stay on one version.

Which machines it runs on

Every image is built for particular CPU types. This one ships for amd64, arm64, arm/v6, 386, ppc64le, s390x, arm64/v8, so it runs on both regular x86 servers and ARM boards like a Raspberry Pi.

Ports

A port is the door the app answers on. A mapping like 1883:1883 means it's reachable on port 1883 of your server, where the left number is yours to change and the right one belongs to the app. It opens:

  • 1883:1883
  • 9001:9001

Volumes

A volume is where Eclipse Mosquitto MQTT keeps its files so they survive an update or a restart. Without one, anything it saves would sit inside the container and vanish the moment it's recreated. This template mounts:

  • /mosquitto/config from /portainer/Files/AppData/Config/eclipse-mosquitto/config on the host
  • /mosquitto/data from /portainer/Files/AppData/Config/eclipse-mosquitto/data on the host
  • /mosquitto/log from /portainer/Files/AppData/Config/eclipse-mosquitto/log on the host

Restart policy

The restart policy here is unless-stopped, so Docker restarts Eclipse Mosquitto MQTT after a crash or reboot, but leaves it off when you stop it on purpose. You can change this on the deploy screen. The choices are no (never restart), on-failure (only after a crash), unless-stopped (restart unless you stop it), and always (bring it back no matter what).

Networking

Nothing custom is set, so Eclipse Mosquitto MQTT sits on Docker's default bridge network: its own private space that reaches the outside world only through the ports it publishes.

Container name

Once it's deployed, Portainer names the container eclipse-mosquitto. That's what you'll spot in the containers list and use in commands like docker logs eclipse-mosquitto.

Platform

The platform is linux, the kind of system the container is built to run on. Docker and Portainer handle this on a normal Linux server.

Portainer app templates

Zooming out, this whole page comes from a Portainer app template: a short recipe telling Portainer how to set Eclipse Mosquitto MQTT up. Add the template list to Portainer once, then deploying Eclipse Mosquitto MQTT is a click rather than a wall of config.