-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ refact(docker): Remove docker compose version (#7)
Also: - refact volumes part to have dedicated folders with valid rights - update documentation
- Loading branch information
Showing
4 changed files
with
31 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
data/mosquitto.db | ||
log/mosquitto.log | ||
config/mosquitto.conf | ||
config/password.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,63 @@ | ||
# Simple Mosquitto broker | ||
|
||
![Mosquitto Logo](https://mosquitto.org/images/mosquitto-text-side-28.png 'Mosquitto') | ||
|
||
# Simple Mosquitto broker | ||
This is a simple [Mosquitto](https://mosquitto.org) broker to quickly initialize projects requiring an MQTT broker. | ||
|
||
This is a simple [Mosquitto](https://mosquitto.org) broker to to quickly initialize projects requiring an MQTT broker. The config file is in the folder `config/mosquitto.conf`. | ||
## Prerequisite | ||
|
||
By default we activated the log and data persistance (respectively in `log` and `data` folder). | ||
The authentication can be activated if needed. | ||
- [Docker](https://www.docker.com/) | ||
- [Docker compose](https://docs.docker.com/compose/) +v1.27.0 (better to have v2) | ||
|
||
# How to use | ||
## How to use | ||
|
||
To start the container, just : | ||
|
||
``` | ||
docker-compose up -d | ||
```bash | ||
UID=$UID GID=$GID docker-compose up -d | ||
``` | ||
|
||
The Mosquitto broker is now available on localhost. You can test it easily (require Mosquitto client): | ||
|
||
| In one shell: | ||
|
||
``` | ||
```bash | ||
mosquitto_sub -h localhost -t "sensor/temperature" | ||
``` | ||
|
||
| In a second shell: | ||
|
||
``` | ||
```bash | ||
mosquitto_pub -h localhost -t sensor/temperature -m 23 | ||
``` | ||
|
||
# Enabling authentication | ||
## Configuration | ||
|
||
The config file is in the file [mosquito.conf](./config/mosquitto.conf) | ||
|
||
By default we activated the log and data persistance (logs are in the `log` folder, and data are stored in a docker voume). | ||
|
||
## Authentication | ||
|
||
### Enable authentication | ||
|
||
In the config file, just uncomment the `Authentication` part and then restart the container. | ||
The default user is `admin/password`. | ||
|
||
**You always have to restart if you want the modification to be taken in account:** | ||
|
||
``` | ||
```bash | ||
docker-compose restart | ||
``` | ||
|
||
## Change user password / create a new user: | ||
### Change user password / create a new user | ||
|
||
``` | ||
```bash | ||
docker-compose exec mosquitto mosquitto_passwd -b /mosquitto/config/password.txt user password | ||
``` | ||
|
||
## Delete user: | ||
### Delete user | ||
|
||
``` | ||
```bash | ||
docker-compose exec mosquitto mosquitto_passwd -D /mosquitto/config/password.txt user | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
version: "3" | ||
|
||
services: | ||
mosquitto: | ||
image: eclipse-mosquitto:2 | ||
volumes: | ||
- ./:/mosquitto/:rw | ||
- ./config/:/mosquitto/config/:ro | ||
- ./log/:/mosquito/log/ | ||
- data:/mosquito/data/ | ||
ports: | ||
- 1883:1883 | ||
- 9001:9001 | ||
|
||
volumes: | ||
data: ~ |
Empty file.