HomeGenie in a dockerized container

@Bounz I remember you discussing the subject of running HG in a dockerized container. I’m assuming you ran it in a Windows Docker. I’m looking at the possibility of running it in a Linux Docker but there’s not much around on this subject.

Do you have any advice you could give me on this.

Hi Peter!

No-no, no Windows containers, never))) Why did you assume that?

I use dockerized version of my HG fork on RPi 3 at home, everything what I use works well, take a look at this post: V1.1.21 released.

They do say that Assumption is the Mother of All F*** Ups :joy: I know now.

Yes I couldn’t remember where you posted your dockerized instructions. Thanks for that Alex.

Using your link and deploying a similar setup to yourself the Docker is not connecting to the socket and it’s reporting a dependency issue. I imagine your Docker was installed on Raspbian Stretch while I am using Raspbian Buster.

If you get a chance could you have a look at how your Docker HGBE install script performs on Raspbian Buster. TIA.

Tested installation script with fresh Buster sd-card and everything works.
Here is an installation progress log:

Summary
Linux raspberrypi 4.19.97-v7+ #1294 SMP Thu Jan 30 13:15:58 GMT 2020 armv7l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.

SSH is enabled and the default password for the 'pi' user has not been changed.
This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.

[email protected]:~ $ wget -qO- https://raw.githubusercontent.com/Bounz/HomeGenie-BE/master/Utils/HgBootstrapper/docker/installer.sh | bash
_  _ ____ _  _ ____ ____ ____ _  _ _ ____    ___  ____ _  _ _  _ ___     ____ ___  _ ___ _ ____ _  _
|__| |  | |\/| |___ | __ |___ |\ | | |___    |__] |  | |  | |\ |   /     |___ |  \ |  |  | |  | |\ |
|  | |__| |  | |___ |__] |___ | \| | |___    |__] |__| |__| | \|  /__    |___ |__/ |  |  | |__| | \|

Enter installation path [/usr/local/bin/hgbe]:

Install docker
# Executing docker install script, commit: f45d7c11389849ff46a6b4d94e0dd1ffebca32c1
+ sudo -E sh -c apt-get update -qq >/dev/null
+ sudo -E sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq apt-transport-https ca-certificates curl >/dev/null
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
  LANGUAGE = (unset),
  LC_ALL = (unset),
  LC_CTYPE = "UTF-8",
  LC_TERMINAL = "iTerm2",
  LANG = "en_GB.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_GB.UTF-8").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
+ sudo -E sh -c curl -fsSL "https://download.docker.com/linux/raspbian/gpg" | apt-key add -qq - >/dev/null
Warning: apt-key output should not be parsed (stdout is not a terminal)
+ sudo -E sh -c echo "deb [arch=armhf] https://download.docker.com/linux/raspbian buster stable" > /etc/apt/sources.list.d/docker.list
+ sudo -E sh -c apt-get update -qq >/dev/null
+ [ -n  ]
+ sudo -E sh -c apt-get install -y -qq --no-install-recommends docker-ce >/dev/null
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
  LANGUAGE = (unset),
  LC_ALL = (unset),
  LC_CTYPE = "UTF-8",
  LC_TERMINAL = "iTerm2",
  LANG = "en_GB.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_GB.UTF-8").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
+ sudo -E sh -c docker version
Client: Docker Engine - Community
Version:           19.03.5
API version:       1.40
Go version:        go1.12.12
Git commit:        633a0ea
Built:             Wed Nov 13 07:37:22 2019
OS/Arch:           linux/arm
Experimental:      false

Server: Docker Engine - Community
Engine:
  Version:          19.03.5
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.12
  Git commit:       633a0ea
  Built:            Wed Nov 13 07:31:17 2019
  OS/Arch:          linux/arm
  Experimental:     false
containerd:
  Version:          1.2.10
  GitCommit:        b34a5c8af56e510852c35414db4c1f4fa6172339
runc:
  Version:          1.0.0-rc8+dev
  GitCommit:        3e425f80a8c931f88e6d94a8c831b9d5aa481657
docker-init:
  Version:          0.18.0
  GitCommit:        fec3683
If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:

  sudo usermod -aG docker pi

Remember that you will have to log out and back in for this to take effect!

WARNING: Adding a user to the "docker" group will grant the ability to run
        containers which can be used to obtain root privileges on the
        docker host.
        Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
        for more information.
Docker intallation complete

Installing HomeGenie (Bounz Edition) into /usr/local/bin/hgbe
Created symlink /etc/systemd/system/multi-user.target.wants/hgbe.service → /etc/systemd/system/hgbe.service.
latest: Pulling from bounz/homegenie
433444f4a04d: Pull complete
65857bb126a3: Pull complete
6215cb271f67: Pull complete
5e9e9462aeb2: Pull complete
bd341f168972: Pull complete
5b97d284ae33: Pull complete
a48d7e3435d4: Pull complete
86067548a7a8: Pull complete
2c532018bbd9: Pull complete
Digest: sha256:b7af1bb8c50c9c99fa572c71892a069763f6767bb99ad035d65fd87aa5653ec6
Status: Downloaded newer image for bounz/homegenie:latest
docker.io/bounz/homegenie:latest
HomeGenie (Bounz Edition) successfully installed
Use following commands to start/stop service:
    sudo systemctl start hgbe
    sudo systemctl stop hgbe
[email protected]:~ $

and after that HG is accessible via web browser displaying demo setup (it uses 80 port by default):

Please, provide more details and/or logs.

Output of your Docker Install script

# Executing docker install script, commit: f45d7c11389849ff46a6b4d94e0dd1ffebca3                                                                                                                          2c1
+ sudo -E sh -c apt-get update -qq >/dev/null
+ sudo -E sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq apt-transp                                                                                                                          ort-https ca-certificates curl >/dev/null
+ sudo -E sh -c curl -fsSL "https://download.docker.com/linux/raspbian/gpg" | ap                                                                                                                          t-key add -qq - >/dev/null
Warning: apt-key output should not be parsed (stdout is not a terminal)
+ sudo -E sh -c echo "deb [arch=armhf] https://download.docker.com/linux/raspbia                                                                                                                          n stretch stable" > /etc/apt/sources.list.d/docker.list
+ sudo -E sh -c apt-get update -qq >/dev/null
+ [ -n  ]
+ sudo -E sh -c apt-get install -y -qq --no-install-recommends docker-ce >/dev/n                                                                                                                          ull
E: Sub-process /usr/bin/dpkg returned an error code (1)
Docker intallation complete

Output of journalctl -xe

Feb 10 18:58:16 raspberrypi dockerd[21700]: Perhaps iptables or your kernel needs to be upgraded.
Feb 10 18:58:16 raspberrypi dockerd[21700]:  (exit status 3)
Feb 10 18:58:16 raspberrypi systemd[1]: docker.service: Main process exited, code=exited, status=1/FAILURE
Feb 10 18:58:16 raspberrypi systemd[1]: Failed to start Docker Application Container Engine.
-- Subject: Unit docker.service has failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- Unit docker.service has failed.
--
-- The result is failed.
Feb 10 18:58:16 raspberrypi systemd[1]: docker.service: Unit entered failed state.
Feb 10 18:58:16 raspberrypi systemd[1]: docker.service: Failed with result 'exit-code'.
Feb 10 18:58:18 raspberrypi systemd[1]: docker.service: Service hold-off time over, scheduling restart.
Feb 10 18:58:18 raspberrypi systemd[1]: Stopped Docker Application Container Engine.
-- Subject: Unit docker.service has finished shutting down
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- Unit docker.service has finished shutting down.
Feb 10 18:58:18 raspberrypi systemd[1]: Closed Docker Socket for the API.
-- Subject: Unit docker.socket has finished shutting down
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- Unit docker.socket has finished shutting down.
Feb 10 18:58:18 raspberrypi systemd[1]: Stopping Docker Socket for the API.
-- Subject: Unit docker.socket has begun shutting down
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- Unit docker.socket has begun shutting down.
Feb 10 18:58:18 raspberrypi systemd[1]: Starting Docker Socket for the API.
-- Subject: Unit docker.socket has begun start-up
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- Unit docker.socket has begun starting up.
Feb 10 18:58:18 raspberrypi systemd[1]: Listening on Docker Socket for the API.
-- Subject: Unit docker.socket has finished start-up
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- Unit docker.socket has finished starting up.
--
-- The start-up result is done.
Feb 10 18:58:18 raspberrypi systemd[1]: docker.service: Start request repeated too quickly.
Feb 10 18:58:18 raspberrypi systemd[1]: Failed to start Docker Application Container Engine.
-- Subject: Unit docker.service has failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- Unit docker.service has failed.
--
-- The result is failed.
Feb 10 18:58:18 raspberrypi systemd[1]: docker.socket: Unit entered failed state.
Feb 10 18:58:18 raspberrypi systemd[1]: docker.service: Unit entered failed state.
Feb 10 18:58:18 raspberrypi systemd[1]: docker.service: Failed with result 'exit-code'.```

`

This is the output of sudo dockerd

INFO[2020-02-10T19:15:19.446335711Z] parsed scheme: "unix"                         module=grpc
INFO[2020-02-10T19:15:19.446444357Z] scheme "unix" not registered, fallback to default scheme  module=grpc
INFO[2020-02-10T19:15:19.446554825Z] ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.sock 0  <nil>}] <nil>}  module=grpc
INFO[2020-02-10T19:15:19.446609929Z] ClientConn switching balancer to "pick_first"  module=grpc
INFO[2020-02-10T19:15:19.451254655Z] parsed scheme: "unix"                         module=grpc
INFO[2020-02-10T19:15:19.452018090Z] scheme "unix" not registered, fallback to default scheme  module=grpc
INFO[2020-02-10T19:15:19.452350069Z] ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.sock 0  <nil>}] <nil>}  module=grpc
INFO[2020-02-10T19:15:19.452631057Z] ClientConn switching balancer to "pick_first"  module=grpc
ERRO[2020-02-10T19:15:19.465117635Z] 'overlay' not found as a supported filesystem on this host. Please ensure kernel is new enough and has overlay support loaded.  storage-driver=overlay2
ERRO[2020-02-10T19:15:19.474322503Z] AUFS was not found in /proc/filesystems       storage-driver=aufs
ERRO[2020-02-10T19:15:19.483117894Z] 'overlay' not found as a supported filesystem on this host. Please ensure kernel is new enough and has overlay support loaded.  storage-driver=overlay
WARN[2020-02-10T19:15:20.043358629Z] Your kernel does not support cgroup memory limit
WARN[2020-02-10T19:15:20.043557951Z] Your kernel does not support cgroup cfs period
WARN[2020-02-10T19:15:20.043642587Z] Your kernel does not support cgroup cfs quotas
WARN[2020-02-10T19:15:20.043716284Z] Your kernel does not support cgroup rt period
WARN[2020-02-10T19:15:20.043788732Z] Your kernel does not support cgroup rt runtime
WARN[2020-02-10T19:15:20.043864409Z] mountpoint for pids not found
INFO[2020-02-10T19:15:20.045094926Z] Loading containers: start.
WARN[2020-02-10T19:15:20.062378312Z] Running modprobe bridge br_netfilter failed with message: modprobe: ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() could not open moddep file '/lib/modules/4.14.71-v7+/modules.dep.bin'
modprobe: WARNING: Module bridge not found in directory /lib/modules/4.14.71-v7+
modprobe: ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() could not open moddep file '/lib/modules/4.14.71-v7+/modules.dep.bin'
modprobe: WARNING: Module br_netfilter not found in directory /lib/modules/4.14.71-v7+
, error: exit status 1
WARN[2020-02-10T19:15:20.087061989Z] Running iptables --wait -t nat -L -n failed with message: `iptables v1.6.0: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.`, error: exit status 3
INFO[2020-02-10T19:15:20.630741519Z] stopping event stream following graceful shutdown  error="<nil>" module=libcontainerd namespace=moby
failed to start daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain DOCKER: iptables failed: iptables -t nat -N DOCKER: iptables v1.6.0: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
 (exit status 3)```

@Bounz thanks for looking but I sorted that out. Iptables weren’t updated. Done now. Thanks again.

Great you were able to solve the problem!

Btw, my installation script doesn’t install docker command-by-command, it just calls docker’s script via wget -qO- https://get.docker.com | sh.

Yes I saw that. There’s been so much discussed about Docker difficulties since the introduction of Buster I thought that might be causing the problem. I had a good look through the log as I have a bit of time and the problem was staring at me. Thanks again.

@Bounz I’m curious to know the contents of your hgbe.service file

Are you using UTF8. It seems that the hgbe.service, the start.sh and stop.sh somehow truncated their contents on ExecStart. I adjusted them accordingly and all are working fine. Loved the bit of Cyrillic on the service file and the scripts.

HG is a different beast running in Docker.I never got a chance to test it before.It’s so much more responsive.No lag on loading.Just runs in the background unnoticed.I’ll get a chance later in the week to put it through it’s paces.Nice job.Pity the HG author never saw fit to Dockerize his application.

Obviously you’re HGBE is still using Weather Underground. I still have one of the old WU API keys which was working when I last used it. Unfortunately the weather data is not being fetched from the WU service and returns the error

“Unable to get data from service. String does not contain a definition for Moon Phase”

Before I look into this further do you use a free api key or a paid one.

It’s available on GitHub https://github.com/Bounz/HomeGenie-BE/blob/master/Utils/HgBootstrapper/docker/hgbe.svc

Sorry, didn’t fix it after local developing and debugging :joy:

Actually I don’t use WU or any other weather programs/widgets as I don’t need information about weather in HG. When I want to know outside temperature I ask Alexa =)

I thought I saw you posting your weather widget with current settings. Not to worry. I’m pulling down data from Dark Sky so it shouldn’t be an issue. I’m making my own weather station using the Pi Sense Hat. Random weather reports are pretty useless anyway.

Alex and Alexa. Now there’s some partnership. Does your halo turn blue when your wife calls you :joy:

Hahaha :rofl:
No, in Russian name Alexander has pet form “Sasha”, so there is no problem with Alexa))