I am running Mosquitto under Docker on a RPi but am having three problems:
- No log file
- No persistent database
- No access from outside the container
The docker-compose.yaml
file is:
version: '3.7'
services:
mosquitto:
container_name: mosquitto
image: eclipse-mosquitto:latest
volumes:
- ~/.docker/mosquitto/data:/mosquitto/data
- ~/.docker/mosquitto/config:/mosquitto/config
- ~/.docker/mosquitto/log:/mosquitto/log
networks:
- nginx
restart: always
networks:
nginx:
name: nginx
and, mosquitto.conf
is
allow_anonymous true
autosave_interval 600
listener 1883
log_dest file /mosquitto/log/mosquitto.log
persistence true
persistence_location /mosquitto/data/
I can access it from inside the container by having two open windows and using the commands:
docker exec -it mosquitto mosquitto_sub -t test -q 1
docker exec -it mosquitto mosquitto_pub -t test -m hello -q 1
but cannot access it from the host using any of the following MQTT X commands:
mqttx pub -h localhost -t test -m hello -p 1883 (localhost)
mqttx pub -h 192.168.0.4 -t test -m hello -p 1883 (intranet host address)
mqttx pub -h 172.19.0.4 -t test -m hello -p 1883 (nginx network container address)
Any help will be greatly appreciated.