My Docker Stack

Yup, they do indeed, but unfortunately, I couldn’t get it to work that way, tried a couple of different times for a good few hours each time messing around, googling, trying different things, and finally the only way I could get it to work was that way.

Hence my quesiton, any idea on an easy way how to keep it permanant through container restarts. I could just install everything in a venv, but would prefer to try and keep it all in a docker stack.

Many thanks in advance.

You can build your own container off the home assistant image and inject what you need in it.

The better option would be to help the devs fix it. :wink:

Well, considering I am having problems building a basic docker container, it also took me three atempts, probably of around 3 hours each to just get it working by following a guide I linked to above. Chance of me fixing a component I know nothing about, yeah.

Guess I carry on googling how to build a container then :wink:

There’s more to helping the devs fix it than writing code.

Is there a bug report on it already? Has it been assigned to someone? Are the devs even aware there is a problem?

That’s where I would start.

I use Traefik as well… what are you having issues configuring? I like the fact that I can just put a few labels on a container and all of the forwarding is setup automagically. For example, I just do this in my docker-compose.yml file:

    labels: 
      - traefik.enable=true
      - traefik.frontend.rule=Host:example.mydomain.com
      - traefik.port=7878
      - traefik.protocol=http

Traefik sees the labels and automatically creates the reverse proxy.

For reference my traefik.toml file looks like:

debug = false  
logLevel = "WARN"
defaultEntryPoints = ["https","http"]

# tell it to listen on 80 and 443, redirecting 80 to 443
[entryPoints]
  [entryPoints.http]
  address = ":80"
    [entryPoints.http.redirect]
    entryPoint = "https"
  [entryPoints.https]
  address = ":443"
    [entryPoints.https.tls]

[retry]

# Tell it where Docker is
[docker]
endpoint = "unix:///var/run/docker.sock"
domain = "mydomain.com"
watch = true
exposedByDefault = false

# Let's Encrypt Cert Setup
[acme]
email = "[email protected]"
storage = "acme.json"
entryPoint = "https"
[acme.dnsChallenge]
provider = "cloudflare"
[[acme.domains]]
  main = "*.mydomain.com"
  sans = ["mydomain.com"]
1 Like

I’m also using Traefik.
Never had any problem with it.
IMHO it is relatively easy to configure.

So from the doc’s,

For MS SQL Server you may have to install a few dependencies:

$ sudo apt-get install freetds-dev
$ pip3 install pymssql

So there is nothing wrong with the component, it just has dependancies, which obviously the docker image doesn’t contain.

So would any happen to know of a handy guide or can point me in the correct direction of how I can use an already built image I guess of HA, but have it add in the pip3 install pymssql and keep that command over restarts.

As @flamingm0e has already said, I need to build one, but I dont believe I need to build one from scratch which is all I can really finding when I try and google stuff.

Any help is very much appricated .

But what db do you want to use. Microsoft Sql server or MySql? I am confused. The string you use is for MsSql not MySql

Yes, the docs were written with the normal python version of home assistant installed in mind.

Which is why I said you should create an issue in the bug tracker so it can get added…I don’t know why I’m having to spell all this out. It seems super simple to me.

I didn’t say you needed to build anything from scratch. You use the home assistant image, and add to it to create your own image. That’s how docker works.

So maybe would have been helpful to explain this. Not everyone has as much knowledge as everyone else in all subjects, hence this forum exists to try and help people out. You first told me the doc’s state it should work, then that it wasn’t actually written for docker.

You can probably tell from my post’s I am new to docker, so going and creating a bug report about something I know nothing about seems counter intuitive, let me post about something I know nothing about saying it isn’t working, when it is probably down to user error.

But its all good, I have sorted it out myself, and got it working.

Not sure why I would have to explain this. Since you aren’t supposed to modify running docker containers, it seems like common sense, that you don’t do this to running docker containers…perhaps I don’t grasp your level of docker knowledge.

So let me help you out for the future here:

If the docs tell you you need to install something, and you are running in Docker, know that it is intended for the python installed version of Home Assistant.

I didn’t say the DOCS state it should work. I told you that you should never have to MODIFY your docker image, and that it should ‘just work’. Out of all the components I have messed with in Home Assistant, I have NEVER, not once, had to modify my docker container, because that’s not how docker works.

What?

This actually doesn’t have to do with Docker directly. You just need to raise an issue with the Home Assistant devs to get whatever you need installed, added to the Docker image. You don’t have to know a damn thing about Docker. All you have to do is state:

“This component doesn’t work in the Docker image, without installing <package>. Please add the package to the docker image.”

Since I use Postgresql and it works out of the box, I cannot go and add this issue for you because I have no first hand knowledge with the mysql or the mssql options. This problem will simply exist until someone steps up and puts in the report and requests that it get changed.

How did you get it working? Did you switch to something different? Is it working without pymysql or pymssql since you have posted questions about both? We’re not sure which SQL you are using actually.

I was trying to update the OP, but it looks like I cannot edit at the moment, so here are some updates to my stack.

version: '3.1'
services:
  unifi:
    container_name: unifi
    restart: unless-stopped
    image: linuxserver/unifi
    volumes:
      - /srv/docker/unifi:/config
    environment:
      - PGID=0
      - PUID=0
      - ES_JAVA_OPTS='-Xms2g -Xmx2g'
    ports:
      - "8080:8080"
      - "8081:8081"
      - "8443:8443"
      - "8843:8843"
      - "8880:8880"
      - "3478:3478"
  syncthing:
    container_name: hass-sync
    restart: unless-stopped
    image: linuxserver/syncthing
    volumes:
      - /srv/docker/syncthing:/config
      - /srv/docker/hass-config:/sync
      - /etc/localtime:/etc/localtime:ro
    network_mode: host
    environment:
      - PGID=0
      - PUID=0
  mqtt:
    container_name: MQTT
    restart: unless-stopped
    image: eclipse-mosquitto
    privileged: true
    volumes:
      - /srv/docker/mosquitto/config/mosquitto.conf:/mosquitto/config/mosquitto.conf
      - /srv/docker/mosquitto/log:/mosquitto/log
      - /srv/docker/mosquitto/data:/mosquitto/data
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "1883:1883"
      - "9001:9001"
  mongo:
    container_name: mongo
    restart: unless-stopped
    image: mongo
    volumes:
      - /srv/docker/mongo:/data/db
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "27017:27017"
  hadockermon:
    container_name: ha-dockermon
    restart: unless-stopped
    image: philhawthorne/ha-dockermon
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /srv/docker/ha-dockermon:/config
    ports:
      - "8126:8126"
  postdb1:
    container_name: postdb1
    restart: unless-stopped
    image: postgres:10.6
    volumes:
      - /srv/docker/postdb1:/var/lib/postgresql/data
      - /etc/localtime:/etc/localtime:ro
    environment:
      - POSTGRES_USER='hass'
      - POSTGRES_PASSWORD='mysupersecretpassword'
    ports:
      - "5432:5432"
  influxdb:
    container_name: influxdb
    restart: unless-stopped
    image: influxdb
    volumes:
      - /srv/docker/influxdb/influxdb.conf:/etc/influxdb/influxdb.conf:ro
      - /srv/docker/influxdb/db:/var/lib/influxdb
    environment:
      - INFLUX_GRAPHITE_ENABLED='true'
    ports:
      - "8086:8086"
  grafana:
    container_name: grafana
    restart: unless-stopped
    image: grafana/grafana
    depends_on:
      - "influxdb"
    volumes:
      - /srv/docker/grafana:/var/lib/grafana
    ports:
      - "3000:3000"
  chronograf:
    container_name: chronograf
    restart: unless-stopped
    image: chronograf
    depends_on:
      - "influxdb"
    volumes:
      - /srv/docker/chronograf:/var/lib/chronograf
    ports:
      - "8888:8888"
  homeassistant:
    container_name: home-assistant
    restart: unless-stopped
    image: homeassistant/home-assistant
    depends_on:
      - "influxdb"
      - "postdb1"
    devices:
      - /dev/ttyACM0:/dev/ttyACM0
    volumes:
      - /srv/docker/hass-config:/config
      - /etc/localtime:/etc/localtime:ro
      - /srv/docker/hass_media:/media
    network_mode: host
    privileged: true
  nodered1:
    container_name: node-red-1
    restart: unless-stopped
    image: nodered/node-red-docker:v8
    depends_on:
      - "homeassistant"
    user: root
    volumes:
      - /srv/docker/node-red-1/user:/data
      - /etc/localtime:/etc/localtime:ro
      - /root/.ssh:/root/.ssh:ro
    ports:
      - "1880:1880"

I no longer keep portainer in the stack, as it was easier to just run that one-off command every so often when I want to update portainer, and honestly, portainer doesn’t get much use any more.

For the most part, not much has changed, and I update my containers weekly with docker-compose pull && docker-compose down && docker-compose up -d

I dropped the speed-test (because on my terrible internet connection, it would kill everyone’s internet in the house every time it ran).

I added the right tag in the node-red service for v8 of nodejs, and some of you might ask about the - /root/.ssh:/root/.ssh:ro line. This is so I can use the ‘projects’ feature in node-red and use my SSH key to publish my changes to my git repo.

I upgraded my postgresql to 10.6 and that was a nightmare. Postgresql has not made it easy to upgrade major versions within Docker. I will be sticking with 10.6 for a while.

Aside from those couple of changes, it is still the same stack and still rock solid, with no issues.

2 Likes

any difference from version 3? Any reason to change?

1 Like

Actually I should update to 3.7 but really it was just to keep up with docker-compose versioning

Yes I see 3.7 is available… do I just edit the yml file with the new version? I’m on 3 now and assume (haha) there’s no problem if I do that

yeah, should be fine.

it seems to be. It’s a pity that docker-compose doesn’t get updated along with everything else… docker keeps up to date but not compose

@flamingm0e:
Could you elaborate on the differences between the containers in you stack regarding whether you choose to run a container as privileged: true or with environment variables PGID=0 and PUID=0?

Isn’t both giving the container root privileges?

Thanks in advance - guess you have your reasons - trying to learn from the experts :wink:

Yeah, six in one hand, half a dozen in the other. No rhyme or reason, other than what some of the docker images suggested.

1 Like

Thanks :wink: