Problem with network and mqtt configuration

Hello,

I have problems with understanging networking in Docker.

I have following configuration of docker-compose:

version: '2'
services:
  homeassistant:
    container_name: home-assistant
    image: homeassistant/raspberrypi3-homeassistant
    volumes:
      - ./homeassistant/config:/config
      - /etc/localtime:/etc/localtime:ro
    devices:
      - /dev/ttyACM0:/dev/ttyACM0
    network_mode: "host"
    privileged: true
    restart: unless-stopped
    ports:
      - 8123:8123

  portainer:
    container_name: portainer
    image: portainer/portainer:latest
    ports:
      - 9000:9000
    networks:
      - local
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - portainer-data:/data

  mosquitto:
    container_name: mosquitto
    build: mosquitto/build
    image: mosquitto
    ports:
        - 1883:1883
        - 9001:9001
    networks:
      - local

networks:
  local:
    driver: bridge

volumes:
  portainer-data:

and following HA config

homeassistant:
  name: Home
  latitude: xxx
  longitude: xxx
  elevation: xxx
  unit_system: metric
  time_zone: Europe/Warsaw
  customize: !include customize.yaml

zone:
  - name: Home
    latitude: xxx
    longitude: xxx
    radius: 100
    icon: mdi:home
  - name: Krzysztof_work
    latitude: 52.232071
    longitude: 20.984099
    radius: 100
    icon: mdi:hospital-building

zwave:
  usb_path: /dev/ttyACM0

device_tracker:
  - platform: nmap_tracker
    home_interval: 10
    hosts: 192.168.1.20-40

mqtt:
  broker: mosquitto
  port: 1883
  client_id: home_assistant_1

The issue is that HA claims, that it cannot connect to mosquitto service. What is interesting, this service is accessible from my host network (through Chrome MQTT Lense app).

It looks like MQTT service is visible outside docker stack, but within it, it is not visible. I am not sure, what name / address shall be put in mqtt broker settings.
Anyone has this working?

I posted this in the other thread but here it is again:

docker run -itd --name=eclipse-mosquitto -p 1884:1883 -p 9002:9001 -v /home/finity/docker/mqtt/config/mosquitto.conf:/mosquitto/config/mosquitto.conf -v /home/finity/docker/mqtt/config/passwd:/mosquitto/config/passwd -v /home/finity/docker/mqtt/data:/mosquitto/data -v /home/finity/docker/mqtt/log:/mosquitto/log -e PGID=1000 -e PUID=1000 -e UMASK_SET=000 eclipse-mosquitto

mqtt:
  broker: 192.168.1.11
  port: 1884
  client_id: home-assistant-4
  username: !secret MQTT_user  
  password: !secret MQTT_password

Thank you very much.It started to work.
The other problem was that my mosquitto version was too old so I had to prepare new Docker image for latest version. Now I have problems with access to files… problems problems… this is why we do it probably :slight_smile: