site_treelogo
  -   Terms of Use and Privacy
Apps | GNU/Linux | Meta
cutup   rss
site_treelogo
  -   Terms of Use and Privacy
Apps | GNU/Linux | Meta
cutup   rss

<<   <   >   >>

2021-02-16 | Apps | Running Mosquitto on Docker on L1G3R

Just run this command to bring up a Mosquitto instance:

docker run -it -p 1883:1883 -v ~/docker-mosquitto/mosquitto/:/mosquitto/ eclipse-mosquitto

The first time it runs, you'll see something like this as the image is downloaded:

Unable to find image 'eclipse-mosquitto:latest' locally
latest: Pulling from library/eclipse-mosquitto
801bfaa63ef2: Pull complete 
0613e57f5869: Pull complete 
99e1cb91ed0c: Pull complete 
Digest: sha256:688f5cf03b714127e67a6ee6354f11b746b49ebe532740429b9a23429496a3d7
Status: Downloaded newer image for eclipse-mosquitto:latest
1612808287: mosquitto version 2.0.7 starting

Here is how we have the configuration laid out:

root [ /home/divine/docker-mosquitto ]# find .
.
./mosquitto
./mosquitto/log
./mosquitto/config
./mosquitto/config/mosquitto.conf
./mosquitto/data
root [ /home/divine/docker-mosquitto ]# cat ./mosquitto/config/mosquitto.conf
allow_anonymous true
connection_messages true
persistence true
log_timestamp_format %Y-%m-%dT%H:%M:%S
listener 1883
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto.log
root [ /home/divine/docker-mosquitto ]#

Test subscribe:

mosquitto_sub -h localhost -t dfd

Test publish:

mosquitto_pub -q 2 -h localhost -m "hello" -t dfd
mqtt