Skip to content

mmikhan/mosquitto-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Mosquitto on Docker Container

The docker-compose.yml file includes a basic installation of Mosquitto on a Docker container. Clone the repository and follow the given steps below:

  1. Start container: docker compose up -d. Three new directories (config, data, log) will be created.
  2. Get into the relevant container: docker exec -it mqtt sh.
  3. Generate authentication file: mosquitto_passwd -c /mosquitto/config/auth username. Replace the username with your own.
  4. Enter the password once prompt.
  5. Create a configuration file: touch config/mosquitto.conf with the following configurations:
persistence true
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto.log
allow_anonymous false
password_file /mosquitto/config/pwfile
listener 1883
listener 9001
protocol websockets
  1. Restart Docker container: docker compose restart
  2. Test the connection using MQTTX or your preferred MQTT client.
  3. Fill up the username, password, and use localhost as the Host with mqtt:https:// prefix.
  4. Create a new subscription on the client and send a message to the relevant topic to test.

If you prefer a video guide, head to the YouTube video that I published for everyone.

Resources

  1. https://youtu.be/L26JY2NH-Ys
  2. https://youtu.be/Bz2JYxbkmuY
  3. https://hub.docker.com/_/eclipse-mosquitto
  4. https://mosquitto.org/man/mosquitto-conf-5.html
  5. https://github.com/eclipse/mosquitto
  6. https://raw.githubusercontent.com/eclipse/mosquitto/master/mosquitto.conf

About

Mosquitto on Docker Container

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published