[SOLVED] Problem accessing Mosquiito in docker rootless container

I’m rebuilding my Docker system on a Raspberry Pi (Raspbian Bullseye / 11 64bit Arm8) this time using docker rootless. This went OK following this guide How to Run Rootless Docker Containers

I then installed the docker compose plugin. Next I installed Portainer in rootless mode following this guide Portainer and rootless Docker and was able to access from a web browser on my LAN.

I could not find a rootless guide for Eclipse Mosquitto so using the Portainer compose as a template installed it. However I cannot access it from a web browser on my LAN. I’ve spent many hours looking for a solution without success,

Here is my compose file:

version: "3.8"

    image: portainer/portainer-ce
    container_name: portainer
    restart: always
      - /$XDG_RUNTIME_DIR/docker.sock:/var/run/docker.sock
      - ~/.local/share/docker/volumes:/var/lib/docker/volumes 
      - /home/hms/docker/portainer:/data
      - 8000:8000
      - 9000:9000
      - TZ=Europe/London

    image: eclipse-mosquitto
    container_name: mosquitto
    restart: always
      - /$XDG_RUNTIME_DIR/docker.sock:/var/run/docker.sock
      - /home/hms/docker/mosquitto/data:/mosquitto/data
      - /home/hms/docker/mosquitto/config:/mosquitto/config
      - /home/hms/docker/mosquitto/log:/mosquitto/log
      - 1883:1883
      - 9001:9001    
      - TZ=Europe/London

Looking at the settings via Portainer both containers are using the docker_default

However whilst Portainer is assigned IP address the Mosquitto container has no IP address assigned.

Looking at Portainer’s network page:
Bridge is subnet gateway
docker_default is subnet gateway
host & none are not assigned

On my original and working docker installation mosquitto is defined with network_mode: “host” and I can access it with 192.168.1.yy:1883 from MQTT Explorer on a PC. Adding network_mode: “host” to my new setup does not work either using 192.168.1.zz:1883 . I get “disconnected from server”.

Here is my mosquitto.config file

persistence true
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto.log

listener 1883
## Authentication ##
allow_anonymous true
#password_file /mosquitto/conf/mosquitto.conf

and the the listen rootlesskit entries in sudo netstat -tulpn

Active Internet connections (only servers)
tcp        0      0  *               LISTEN      567/rootlesskit
tcp        0      0  *               LISTEN      567/rootlesskit
tcp6       0      0 :::8000                 :::*                    LISTEN      567/rootlesskit
tcp6       0      0 :::9000                 :::*                    LISTEN      567/rootlesskit

And the last entries in the mosquitto.log

1680865416: mosquitto version 2.0.15 starting
1680865416: Config loaded from /mosquitto/config/mosquitto.conf.
1680865416: Opening ipv4 listen socket on port 1883.
1680865416: Opening ipv6 listen socket on port 1883.
1680865416: mosquitto version 2.0.15 running

Suggestions please.


removed network_mode: “host” from docker-compose.yaml

I had this “host” setting in my previous docker install and that is still working on another pi.