54 lines
1.1 KiB
Markdown
54 lines
1.1 KiB
Markdown
Portainer Stack:
|
|
```yaml
|
|
---
|
|
version: "3.8"
|
|
services:
|
|
mqtt:
|
|
container_name: mqtt
|
|
hostname: mqtt
|
|
image: eclipse-mosquitto:latest
|
|
restart: unless-stopped
|
|
network_mode: bridge
|
|
user: "1000:1000"
|
|
environment:
|
|
- TZ=Europe/Amsterdam
|
|
volumes:
|
|
- /etc/localtime:/etc/localtime:ro
|
|
- /mqtt/config:/mosquitto/config
|
|
- /mqtt/data:/mosquitto/data
|
|
- /mqtt/log:/mosquitto/log
|
|
ports:
|
|
- 9001:9001
|
|
- 1883:1883
|
|
labels:
|
|
- com.centurylinklabs.watchtower.enable=true
|
|
```
|
|
|
|
Mosquitto configuration file `/mosquitto/config/mosquitto.conf`:
|
|
```
|
|
listener 1883
|
|
|
|
persistence true
|
|
persistence_location /mosquitto/data/
|
|
|
|
log_dest file /mosquitto/log/mosquitto.log
|
|
log_dest stdout
|
|
log_type all
|
|
|
|
allow_anonymous false
|
|
password_file /mosquitto/config/passwd
|
|
```
|
|
|
|
Create empty file `/mosquitto/config/passwd`
|
|
And from the terminal create user sending:
|
|
|
|
```
|
|
docker exec -it mqtt usr/bin/mosquitto_passwd -c /mosquitto/config/passwd USERNAME
|
|
```
|
|
|
|
And if you want to add more users use:
|
|
|
|
```
|
|
docker exec -it mqtt usr/bin/mosquitto_passwd -b /mosquitto/config/passwd NEW_USERNAME PASSWORD
|
|
```
|