My Docker Stack

I am struggling with MQTT. I have the image and container but Home Assistant is not connecting to it.
I’m getting this error and I do not see the folders. I tried creating them manually and chmod to 0777.

from my docker-compose:

  mqtt:
    image: eclipse-mosquitto:latest
    container_name: "MQTT"
    restart: always
    ports:
      - "1883:1883"
      - "9001:9001"
    volumes:
      - /MQTT/data:/mosquitto/data
      - /MQTT/config:/mosquitto/config
      - /MQTT/log:/mosquitto/log
    network_mode: "host"

from configuration.yaml:

mqtt:
  broker: core-mosquitto
  username: mqttuser
  password: mqttpass
  discovery: true
  discovery_prefix: homeassistant

Looks like everything else is pretty much working.

If you’re passing ports you don’t need network=host. Use one or the other.

You’re telling home assistant to look for a DNS entry named core-mosquitto. Does that hostname exist on your network? Why not just use the IP address of it?

The directories need to exist before you run your container.

Sorry and thank you but I am stumped… I just keep getting exit code 3… google is not helping me find an answer. The folders are created but empty.

I see in the image that there should be this: /usr/sbin/mosquitto but I do not have this. Do I need to install mosquitto separately?

Literally everything else I have from my previous install/system appears to be working well.

no.

The host does NOT need the same applications installed as what is in the Docker. That would defeat the ENTIRE reason to use Docker.

The CMD section is the command it is running INSIDE the docker container.

Does /MQTT/{data, config, log} all exist on the host? Those directories HAVE to exist in order for your compose to work.

Yes, so far as I can see

image

I think I found something… still poking around. Found a different log.
image

do you actually have a mosquitto.conf file in your config directory?

There was not, I just now made a default from here: https://raw.githubusercontent.com/eclipse/mosquitto/master/mosquitto.conf

I thought it would have auto-created or installed somehow.

So now it is running but still getting errors for it in home assistant. I’ll start reading the man-page.

Thank you!

Have to give up for now, need to move on to another time-sensitive project. Just reverted back to my old CloudMQTT for now.

It is technically running though I suppose but just have not figured out how to get home assistant to see it.

Thank you for all your help. Definitely running smoother than I was experiencing on my Pi.

I told you. You are telling home assistant to use:

what is ‘core-mosquitto’? Does that hostname exist on your network? Can you ping that hostname and get a response from your Docker host IP?

If you will use the Docker host IP, it should work just fine.

also, you can remove your user and pass, since you havent created the user or pass in mosquitto

I missed that… didn’t see it as a host rather than a default of when I had HassIO. Sheesh, thank you for pointing it out (again). I did get the user/pass to work with mosquitto_passwd -c passwordfile user in etc/mosquitto.

1 Like

Before I start (and it will probably be tomorrow), any tricks I need to know to get SSL set back up?

1 Like

currently pulling out my hair trying to figure this out as well…

Just made the leap to a NUC and trying to get off the ground running HASS in a Docker container. I’ve managed that OK but haven’t been successful trying to setup SSL for secure remote access from my phone outside my home network…

I would recommend doing it via NGINX reverse proxy and Let’s Encrypt.

Then I am hoping all that is possible using docker as well :wink:

So far I like Docker although I am sure it gets even better as one learns more about it.

Of course it is

Thanks for the recommendation. I successfully got the linuxserver/letsencrypt container up and running which I think accomplishes what you’re suggesting (Nginx webserver and reverse proxy with php support and a built-in letsencrypt client).

I’m still seeing the same error in Home Assistant’s logs:

2018-02-17 17:49:45 ERROR (MainThread) [homeassistant.config] Invalid config for [http]: not a file for dictionary value @ data['http']['ssl_certificate']. Got '/opt/docker/letsencrypt/etc/letsencrypt/live/example.duckdns.org/fullchain.pem'
not a file for dictionary value @ data['http']['ssl_key']. Got '/opt/docker/letsencrypt/etc/letsencrypt/live/example.duckdns.org/privkey.pem'. (See /config/configuration.yaml, line 38).

The config.yaml has:

http:
  api_password: !secret http_password
  ssl_certificate: !secret ssl_certificate
  ssl_key: !secret ssl_key
  base_url: !secret base_url

I read through this thread where a similar issue occurred, however I haven’t had any luck applying the chmod solution identified there…

Any ideas or suggestions I can keep pursuing? Appreciate anything you can suggest!

You don’t need to do anything with home assistant config if you’re using a reverse proxy.

Thanks, I removed the SSL key/cert from config.yaml and now receive a
ERR_SSL_PROTOCOL_ERROR instead of connection refused - a sign of progress :slight_smile: . I’ll keep playing around with the let’s encrypt setup to iron out the kinks. Appreciate the help!

The let’s encrypt docker does not handle nginx revers proxy. You need to configure a separate docker for that

The docker hub page for let’sencrypt image indicates it:

sets up an Nginx webserver and reverse proxy with php support and a built-in letsencrypt client that automates free SSL server certificate generation and renewal processes.

Are you saying that in addition to this, I need a separate nginx reverse proxy container?