No Log nor Persistence

I am running Mosquitto under Docker on a RPi but am having three problems:

  1. No log file
  2. No persistent database
  3. 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.

Hi Arkansas-Io Ter,

  1. Have you tried using docker logs mosquitto

  2. How do you see, that the persistence does not work?

  3. To get ports open outside of the docker container, use port mapping in your .yml file. Add e.g.

  ports:
      - 1883:1883