1
2
mirror of https://github.com/vimagick/dockerfiles synced 2024-06-16 03:48:44 +00:00

update mosquitto

This commit is contained in:
kev 2017-04-22 12:19:52 +08:00
parent f0497c44bc
commit 01ad5ff040
4 changed files with 20 additions and 13 deletions

@ -47,13 +47,10 @@ A collection of delicious docker recipes.
## IoT
- [x] docker-compose-arm
- [x] hass
- [x] hass-arm
- [x] hbdg
- [x] hbdg-arm
- [x] hass :+1:
- [x] hbdg :+1:
- [x] node-red :+1:
- [x] node-red-arm :+1:
- [x] mosquitto :+1:
## Daemon

@ -15,7 +15,8 @@ mosquitto:
- "1883:1883"
- "8883:8883"
volumes:
- ./mosquitto.conf:/etc/mosquitto/mosquitto.conf
- ./data/mosquitto.conf:/etc/mosquitto/mosquitto.conf
- ./data/pwfile:/etc/mosquitto/pwfile
- ./data:/var/lib/mosquitto
restart: always
```
@ -25,7 +26,7 @@ mosquitto:
```
port 8883
log_dest stdout
password_file /var/lib/mosquitto/passwd
password_file /etc/mosquitto/pwfile
persistence true
persistence_location /var/lib/mosquitto
cafile /var/lib/mosquitto/ca.crt
@ -34,7 +35,7 @@ keyfile /var/lib/mosquitto/server.key
require_certificate false
```
- `passwd` is managed by [mosquitto_passwd][3].
- `pwfile` is managed by [mosquitto_passwd][3].
- TLS keys are generated by [openssl][2].
> It is important to use different certificate subject parameters for your CA,
@ -43,7 +44,15 @@ require_certificate false
## server
```
$ mkdir -p data
$ touch data/mosquitto.conf data/pwfile
$ docker-compose up -d
$ docker-compose exec mosquitto sh
>>> cd /etc/mosquitto
>>> echo username:password >> data/pwfile
>>> mosquitto_passwd -U passwd
>>> exit
$ docker-compose restart
$ docker-compose logs -f
Attaching to mosquitto_mosquitto_1
mosquitto_1 | 1478107412: mosquitto version 1.4.8 (build date 2016-05-16 14:17:19+0000) starting
@ -59,7 +68,7 @@ mosquitto_1 | 1478107585: Client mosqpub/38324-Kevins-Ma disconnected.
## client
```bash
$ mosquitto_sub -d -h 192.168.31.231 -p 8883 --cafile ca.crt --insecure -t hello
$ mosquitto_sub -d -h 192.168.31.231 -p 8883 --cafile ca.crt --insecure -u username -P password -t hello
Client mosqsub/38158-Kevins-Ma sending CONNECT
Client mosqsub/38158-Kevins-Ma received CONNACK
Client mosqsub/38158-Kevins-Ma sending SUBSCRIBE (Mid: 1, Topic: hello, QoS: 0)
@ -74,7 +83,7 @@ Client mosqsub/38158-Kevins-Ma received PINGRESP
```
```bash
$ mosquitto_pub -d -h 192.168.31.231 -p 8883 --cafile ca.crt --insecure -t hello -m world
$ mosquitto_pub -d -h 192.168.31.231 -p 8883 --cafile ca.crt --insecure -u username -P password -t hello -m world
Client mosqpub/38324-Kevins-Ma sending CONNECT
Client mosqpub/38324-Kevins-Ma received CONNACK
Client mosqpub/38324-Kevins-Ma sending PUBLISH (d0, q0, r0, m1, 'hello', ... (5 bytes))

@ -1,6 +1,7 @@
port 8883
log_dest stdout
password_file /var/lib/mosquitto/passwd
allow_anonymous false
password_file /etc/mosquitto/pwfile
persistence true
persistence_location /var/lib/mosquitto
cafile /var/lib/mosquitto/ca.crt

@ -4,6 +4,6 @@ mosquitto:
- "1883:1883"
- "8883:8883"
volumes:
- ./mosquitto.conf:/etc/mosquitto/mosquitto.conf
- ./data/mosquitto.conf:/etc/mosquitto/mosquitto.conf
- ./data:/var/lib/mosquitto
restart: always