-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmqtt-client.yml
33 lines (31 loc) · 1.61 KB
/
mqtt-client.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# docker-compose -f mqtt-client.yml -p mqtt-client up -d
version: '2.4'
services:
# MQTT-Client CLI based on mosquitto-clients
# (OS: AlpineLinux ; Installed: "apk add --no-cache ca-certificates mosquitto-clients")
# https://github.com/Tob1as/docker-tools
# https://hub.docker.com/r/tobi312/tools
# Supported architectures: arm32v6, arm32v7, arm64v8, amd64
# https://mosquitto.org/man/mosquitto_sub-1.html - read for more information about mosquitto_sub-command
# after start see logs: "docker logs -f mqtt-client"
mqtt-client:
image: tobi312/tools:mqtt-client
container_name: mqtt-client
restart: unless-stopped
#user: "1000:1000" # format: "${UID}:${GID}"
#volumes:
# - /etc/ssl/certs/ca-certificates.crt:/etc/ssl/certs/ca-certificates.crt:ro
environment:
MQTT_HOSTNAME: "mqtt.example.com"
MQTT_PORT: "8883" # 1883 for TCP without SSL or 8883 for TCP with SSL
MQTT_USERNAME: "user"
MQTT_PASSWORD: "passw0rd"
MQTT_TOPICS: '-t #' # example: '-t #' for all topics or '-t topic1/# -t topic2/# -t topic3/#' for specific topic
MQTT_CLIENTNAME: "mqtt-client-0815"
entrypoint: [ "/bin/sh", "-c", "--" ]
#command: [ "while true; do sleep 60; done;" ] # use this, when you want use inside container a other mosquitto_pub/mosquitto_sub-command
command: [ "mosquitto_sub -h $$MQTT_HOSTNAME -p $$MQTT_PORT -u $$MQTT_USERNAME --pw $${MQTT_PASSWORD} $$MQTT_TOPICS --insecure --cafile /etc/ssl/certs/ca-certificates.crt --tls-version tlsv1.2 -i $$MQTT_CLIENTNAME -F '%I %t %p'" ]
networks:
default:
external: true
name: mynetwork