Runnng Openhab2 in a docker

Hi,

I am just beginning and trying to understand the best way to go forward.
I built an Ubuntu server that I want to run on it:

  • Openhab
  • Motioneye
  • Opencv
  • Red Node

I was thinking about running all of it in dockers but as I went over the guide and I see the following:
However, this flexibility comes at a cost. For example, because openHAB is running in its own container with only enough installed to run openHAB, the Exec binding is very likely to be useless to you because the container will not have access to the programs and files you need.

I could not make much of what it means, I would be happy for some advice on the best was to build the server.

Thanks,
Omri

that’s indeed not true at all.
all you have to do is to login to your docker shell and install what you want to use there.
(or you can start container with linked folder to your root sbin/bin, but i do not recommend this at all)

I’m running only in docker in production and I’ll never look back to anything else

You have not given us any detail either. If you do not expect to use theexec binding, just realize the warning does not apply in your solution.

Only YOU can determine what is best. If you provide us more details on what exactly you want to accomplish, we can possibly provide some advice.

Hi Kriznik,

It’s good to hear that it’s a stable solution, and I know that all addons and configuration finds are mapped to the host OS. but if you install more stuff from bash it’s not getting erased when you restart the docker or upgrade?

Bruce,

I am not sure about everything yet - I am planning the system for a new house we are moving in a few months - for now, I am testing different equipment and software and trying to build the best infrastructure for the new house.

The first decision I had to make is Home Assistant vs Openhab after reading a lot and playing I think that Openhab is the best solution for me.

Thanks, guys for the help… I would probably need it in the next few month :slight_smile:

Omri

But if you recreate the container, you will lose your installed programs.

Welcome!

OpenHAB tends to be more stable and slower moving. I think it is more flexible but more complex to learn and implement. There are some very helpful, competent developers here helping users navigate this complexity.

You did not state what OS or hardware platforms you are considering. A Debian-based Linux is likely recommended since that is a primary development target. Although many people here run openHAB on a Raspberry Pi, I personally think a Docker-based configuration should not be run for production on anything less than a Pi 4 with 2GB of RAM.

The forum here is designed more to help you through your configuration rather than provide complete solutions. I personally find the user community here tends to be a little more mature than when I started using Home Assistant a year ago.

My server is with ubuntu based I7 CPU and 32GB RAM, it’s strong but i want it to take care of the other software that I will need, for now, I am thinking about:

  • Openhab
  • Motioneye
  • Opencv
  • Red Node
    and maybe also music streaming…

Not sure what else I can tell at this point…

1 Like

Any idea what technologies? Zigbee and Z-Wave could be good choices and we have a fist class developer IMO.
Where in the world are you located? What is available varies somewhat by region.

I am from Israel…
I am going to use wifi and Z-Waze, also I bought a sonoff rf-wifi since I have some RF sensors…

1 Like

Be sure any Z-Wave products are designed for Israel. It is one of 19 different Z-Wave regions, all with differing RF requirements.

Many product models gave specific versions for differing regions. Some only target one or a subset of regions.

Good point, I have ordered from Amazon the Aeotec Z-Stick Gen5, Z-Wave Plus USB do you know if it needs to be matched as well?

Amazon link?

EDIT: Also verify they send toe correct part. I recently ordered a US stick from a different company and they accidentally shipped a Japan one. I just received a replacement US stick

https://www.amazon.com/dp/B00X0AWA6E/ref=cm_sw_r_other_apa_i_FLNwEb3B255KH

On that Amazon link the only hint is the Z-Wave certification points to the US version. Checking the specification sheet from Aeotec’s site, it appears that stick is only available for US EU and Austrailia frequencies.

Sorry, I guess you will need a different stick for Israel.

Israel uses EU frequencies…

FALSE
According to the Z-Wave Alliance Israel uses 916 MHz. EU uses either 866.4 MHz or 869.85 MHz.
Using EU Z-Wave devices in Israel is likely illegal

Did you get everything set up the way you want?

I’m very pleased with Docker and my Ubuntu server. I’m running containers for:
openHAB
MotionEye
InfluxDB
Grafana
Shairport
Logitech Media Server
Portainer
Emby
Frontail
UniFi poller

I also use and installed directly:
NodeRED
Network UPS Tools
Mosquitto

I love docker but came to embrace a mixed philosophy: Docker when convenient but systemd if there were too many trade offs.

Can you point me to a guide to installing influxDB and Grafana as docker in OH?

Hi Omri, here is my docker-compose.yaml for most services you want to setup. They are all bound in one network (smarthome --> docker create network smarthome). You can start/stop the services with docker compose.

Start: docker-compose up -d
Stop: docker-compose down -v --remove-orphans

version: '3.8'

services:
  mosquitto:
    image: eclipse-mosquitto
    container_name: mosquitto
    restart: unless-stopped
    environment:
      - TZ=Europe/Berlin
      - PUID=1000
      - PGID=1000
    volumes:
      - /opt/docker/smarthome/mosquitto/config:/mosquitto/config
      - /opt/docker/smarthome/mosquitto/data:/mosquitto/data
      - /opt/docker/smarthome/mosquitto/log:/mosquitto/log
    ports:
      - "1883:1883"
      - "9001:9001"
    networks:
      - smarthome

  openhab:
    image: openhab/openhab
    container_name: openhab
    restart: unless-stopped
    ports:
      - 8080:8080
      - 8443:8443
      - 5007:5007
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      - /opt/docker/smarthome/openhab/openhab_addons:/openhab/addons
      - /opt/docker/smarthome/openhab/openhab_conf:/openhab/conf
      - /opt/docker/smarthome/openhab/openhab_userdata:/openhab/userdata
    depends_on:
      - mosquitto
      - motioneye
      - node-red
    environment:
      OPENHAB_HTTP_PORT: "8080"
      OPENHAB_HTTPS_PORT: "8443"
      EXTRA_JAVA_OPTS: "-Duser.timezone=Europe/Berlin"
      LC_ALL: "de_DE.UTF-8"
      LANG: "de_DE.UTF-8"
      LANGUAGE: "de_DE.UTF-8"
      USER_ID: "1000"
      GROUP_ID: "1000"
    networks:
      - smarthome


  node-red:
    image: nodered/node-red
    container_name: node-red
    environment:
      - TZ=Europe/Berlin
    volumes:
      - /opt/docker/smarthome/node-red/data:/data
    ports:
      - 1880:1880
    restart: unless-stopped
    networks:
      - smarthome


  motioneye:
    container_name: motioneye
    image: ccrisan/motioneye:master-amd64
    restart: unless-stopped
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /opt/docker/smarthome/motioneye/etc/motioneye:/etc/motioneye
      - /mnt/storage/docker/smarthome/motioneye:/var/lib/motioneye
    ports:
      - 8765:8765
      - 8081:8081
    networks:
      - smarthome


networks:
  smarthome:
    external: true
1 Like

I haven’t tried Compose much - it’s on my list but at this point I start everything with docker run
and manage it with Portainer. I’ll offer my advice as a parallel to that provided by @MrksHfmn.

I did a short write-up with some Docker advice and your question motivated me to cross post it here:

For InfluxDB, my run command looks like this:

sudo docker run -p 8086:8086 \
	-d \
	--name influxdb \
	-v /opt/influxdb:/var/lib/influxdb \
	-v $PWD/influxdb.conf:/etc/influxdb/influxdb.conf:ro \
	influxdb -config /etc/influxdb/influxdb.conf

For Grafana, I’d recommend creating a Grafana user with appropriate UID and GID (I used 9004). I discussed this in the link I posted.

sudo docker run \
	-d \
	-p 3000:3000 \
	-p 8081:8081 \
	--restart=always \
	--name=grafana \
	--user=9004 \
	-e GF_SECURITY_ALLOW_EMBEDDING=true \
	-e GF_AUTH_ANONYMOUS_ENABLED=true \
	-e GF_RENDERING_SERVER_URL=http://192.168.1.80:8081/render \
	-e GF_RENDERING_CALLBACK_URL=http://198.168.1.80:3000/ \
	-e GF_LOG_FILTERS=rendering:debug \
	-v /opt/grafana/data:/var/lib/grafana \
	grafana/grafana

Note that both of these containers use persistent volumes in the opt directory. I’d recommend creating these directories before creating the containers, and in the case of Grafana, doing some permissions fixes. I talked about that in my write up too.

Hope that’s helpful!

1 Like