openHAB 2 in Docker on a Raspberry Pi3

openHAB 2 in Docker on a Raspberry Pi3

Now that openHAB 2 is released I wanted to update my setup and also use the opportunity to try Docker. I’m pretty much a noob when it comes to linux, so it took me a while to get it running and I hope it’s up to muster. The plan is to have openHAB 2 running in a Docker container, but have file persistence in the host file system. This way one can mess around in the container, delete it and build a new one while not loosing data. So first the folders for persistence have to be created and given the appropriate rights: sudo mkdir /opt/openhab/ sudo mkdir /opt/openhab/conf/ sudo mkdir /opt/openhab/userdata/ sudo mkdir /opt/openhab/addons/ sudo mkdir /opt/openhab/conf/items/ sudo mkdir /opt/openhab/conf/persistence/ sudo mkdir /opt/openhab/conf/rules/ sudo mkdir /opt/openhab/conf/scripts/ sudo mkdir /opt/openhab/conf/services/ sudo mkdir /opt/openhab/conf/sitemaps/ sudo mkdir /opt/openhab/conf/things/ sudo chown 9001.9001 /opt/openhab -R Then the initial configuration files have to be copied into the host folders: docker run --rm --user 9001 -v /opt/openhab/addons:/openhab/addons -v /opt/openhab/conf:/openhab/conf -v /opt/openhab/userdata:/openhab/userdata openhab/openhab:2.0.0-armhf sh -c 'cp -av /openhab/userdata.dist/* /openhab/userdata/ && p -av /openhab/conf.dist/* /openhab/conf/' After that you can build the openHAB container with a normal run command: docker run \ --name openhab \ --net=host \ -v /etc/localtime:/etc/localtime:ro \ -v /etc/timezone:/etc/timezone:ro \ -v /opt/openhab/conf:/openhab/conf \ -v /opt/openhab/userdata:/openhab/userdata \ -v /opt/openhab/addons:/openhab/addons\ -d \ --user=9001 \ --restart=always \ openhab/openhab:2.0.0-armhf With the container running use the following command to access the Karaf shell (default password is habopen) : ssh openhab@localhost -p 8101 Tailing logs can be achieved with: log:tail Raising or lowering the log level (list here): log:set LEVEL package.subpackage eg.: log:set DEBUG org.openhab.binding.zwave Next up: running a mqtt and mysql container…  ...
MQTT, Mosquitto, Raspbian Jessie und der fiese Systemd-Autostart

MQTT, Mosquitto, Raspbian Jessie und der fiese Systemd-Autostart

Disclaimer: Ich hab keine Linuxerfahrung. Mit Google an meiner Seite, bekomme ich Dinge hin, die ich meistens nur halb verstehe. Also falls ich Blödsinn erzähle, bin ich dankbar für einen Hinweis. Immer wieder wenn ich bastle, sehen die Anleitungen super leicht aus – es dauert dann aber doch einen Tag bis alles läuft. Nicht anders war es bei meiner Mosquitto Installation. Die Hürde: kein Autostart. Meine Mosquitto-Config ist simpel und sie sieht wie folgt aus: # Config file for mosquitto # # See mosquitto.conf(5) for more information. # # Default values are shown, uncomment to change. # # Use the # character to indicate a comment, but only if it is the # very first character on the line. # ================================================================= # General configuration # ================================================================= # Write process id to a file. Default is a blank string which means # a pid file shouldn't be written. # This should be set to /var/run/mosquitto.pid if mosquitto is # being run automatically on boot with an init script and # start-stop-daemon or similar. pid_file /var/run/mosquitto.pid # When run as root, drop privileges to this user and its primary # group. # Leave blank to stay as root, but this is not recommended. # If run as a non-root user, this setting has no effect. # Note that on Windows this has no effect and so mosquitto should # be started by the user you wish it to run as. user mosquitto # ================================================================= # Persistence # ================================================================= # Save persistent message data to disk (true/false). # This saves information about all messages, including # subscriptions, currently in-flight messages and retained # messages. # retained_persistence...