My Docker Stack

You should take some more time to understand Docker. LOL.

I completely agree.

Everyone makes it sound pretty straight forward. But it’s only straight forward if you already know the details of what you need to do.

Maybe I’ll just try to get HA installed in the NUC in a python virtual environment instead. I’m sure that’ll be easy, too.:roll_eyes:

Looks interesting and intensive. I am currently running Portainer and probably not fully utilizing it.

Rancher is massive and requires database. It’s so much more than I need for my stack.

How do you setup the db_url to connect to postgres in a docker.
I am getting password auth failed with this

db_url: postgresql://hass:[email protected]:5432/hass

and this as the docker_compose.yaml

postdb1:
    container_name: postdb1
    restart: unless-stopped
    image: postgres:9.6
    volumes:
      - /home/user/docker/postgresql:/var/lib/postgresql/data
      - /etc/localtime:/etc/localtime:ro
    environment:
      - POSTGRES_DB='hass'
      - POSTGRES_USER='hass'
      - POSTGRES_PASSWORD='XXXX'
    ports:
      - "5432:5432"

I would console into the postgresql container and verify the DB, user, and pass were created correctly

Do you need the quotes around the DB, Name and Passwords? I don’t on mine for mysql.

I just came here to say a huge thanks… I have been meaning to look into docker-compose for yonks, today I did and everything works perfect thanks.
Portainer
HA
ha-dockermon
MYSQL
docker-influxdb-grafana
MQTT

That is all I need as I don’t think I would use node-red etc etc

Thanks for the replies!

Unfortunately HA-Dockermon doesn’t allow pulling images according to the documentation.

SSH will probably be the way I go, but I’ve been teaching myself both docker and puppet lately so a quick “hack” that amazingly worked:

  • You can expose docker.sock from the host to the container.
  • In the container, you can pull the latest docker image: curl --unix-socket /var/run/docker.sock -X POST http:/v1.36/images/create?fromImage=homeassistant/home-assistant:latest
  • Finally, next time the puppet agent runs (every 30 mins) it will automatically destroy and recreate the docker container with the latest image (because I have the docker container in the puppet manifest)

Not elegant (or secure?) at all, but fun :'D

1 Like

Thank you for the suggestions. I did log in to postgres container and created the user, database and the password. It took awhile for me to figure out how to log in to the container.

I had everything working in docker but still experimenting with the setup and have not switched over home automations yet.

If you want an easy interface, portainer has an easy way to login to the console of the containers

1 Like

I have the following situation where the hass docker image misses tools like telnet & expect in the standard image. Currently i’m running a script inside docker to add the following apps:

apk update
apk add -u busybox
apk add busybox-extras
apk add expect

I have this included in small script that I run like this manually after an image update:
docker exec -it homeassistant /bin/sh /config/setup.sh

Is there I way to incorporate this in a docker-compose yaml, so when a new hass image is available to have to automatically updated in the container?

version: "3"
services:
  homeassistant:
    container_name: homeassistant
    image: homeassistant/raspberrypi3-homeassistant
    volumes:
      - /opt/docker/hass:/config
      - /etc/localtime:/etc/localtime:ro
    network_mode: host

build a dockerfile that uses homeassistant/home-assistant as FROM and add in your custom pieces. then use your custom docker file in your docker compose.

what are you using telnet and expect for? perhaps there is a better option for what you want to accomplish using the normal image?

Don’t know how to build that file and what to put in, just starting in the docker world after inspiration from this post.

My home-automation communicates only through telnet and I have script that uses “expect” to perform some commands (login/password and execute the action afterwards ie. switch on/off)

command_on: “/usr/bin/expect -f /opt/scripts/apex.sh ‘SetAnalogOut 2,150’”
command_off: “/usr/bin/expect -f /opt/scripts/apex.sh ‘SetAnalogOut 2,0’”

apex.sh:

#!/usr/bin/expect

set timeout 5
set command [lindex $argv 0]

spawn telnet 192.168.1.61 2024

expect “>Ready”
send “\r”
send “Pass password\r”
send “$command\r”
send “\r”
send “Shutdown\r”
send “\r”

Is there some reason you cannot use SSH? telnet is very insecure

Just look at this file:

not clear for me where to add the following in the dockerfile?
apk update
apk add -u busybox
apk add busybox-extras
apk add expect

Also my old home-automation is only available through telnet

Love your docker stack, it’s very similar to my configuration. How do you handle startup timing to avoid Home Assistant coming up before other services (looking at you, MQTT) are finished loading? I have to restart Home Assistant about a minute after the stack comes up since it won’t check for external component after startup. I lose ZoneMinder, Plex and MQTT as they start just slightly slower than Home Assistant.

I’m considering using dockerize to solve the issue but not sure if there is a better way.

Are you using docker compose? You can use “depends on.” See this LINK.

It will start the dependency first, but it does not wait for the startup to be completed. It might solve your issue.

This is what I am using on my NUC, and I don’t have any issues.

Agreed - depends_on works for me. Keeps mqtt, HA, and Homebridge starting in the right order.