Dit is stap 1 van de serie Home-assistant & docker, van aqara tot z-wave in een stap of 10
Zoals gezegd starten we met een verse installatie van Ubuntu 18.04 LTS (Bionic Beaver). Niets is nog geïnstalleerd. Alleen is de installatie bijgewerkt met alle updates.
Docker
Op de console installeren we eerste docker.op met het commando :
sudo apt install docker.io
lbeuker@ubuntu:~$ sudo apt install docker.io Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: bridge-utils cgroupfs-mount git git-man liberror-perl ubuntu-fan Suggested packages: aufs-tools btrfs-tools debootstrap docker-doc rinse zfs-fuse | zfsutils git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-cvs git-mediawiki git-svn The following NEW packages will be installed: bridge-utils cgroupfs-mount docker.io git git-man liberror-perl ubuntu-fan 0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded. Need to get 34.9 MB of archives. After this operation, 171 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 bridge-utils amd64 1.5-15ubuntu1 [30.1 kB] Get:2 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64 cgroupfs-mount all 1.4 [6,320 B] Get:3 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64 docker.io amd64 17.12.1-0ubuntu1 [30.1 MB] Get:4 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 liberror-perl all 0.17025-1 [22.8 kB] Get:5 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 git-man all 1:2.17.1-1ubuntu0.1 [803 kB] Get:6 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 git amd64 1:2.17.1-1ubuntu0.1 [3,905 kB] Get:7 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 ubuntu-fan all 0.12.10 [34.7 kB] Fetched 34.9 MB in 49s (716 kB/s) Preconfiguring packages ... Selecting previously unselected package bridge-utils. (Reading database ... 161532 files and directories currently installed.) Preparing to unpack .../0-bridge-utils_1.5-15ubuntu1_amd64.deb ... Unpacking bridge-utils (1.5-15ubuntu1) ... Selecting previously unselected package cgroupfs-mount. Preparing to unpack .../1-cgroupfs-mount_1.4_all.deb ... Unpacking cgroupfs-mount (1.4) ... Selecting previously unselected package docker.io. Preparing to unpack .../2-docker.io_17.12.1-0ubuntu1_amd64.deb ... Unpacking docker.io (17.12.1-0ubuntu1) ... Selecting previously unselected package liberror-perl. Preparing to unpack .../3-liberror-perl_0.17025-1_all.deb ... Unpacking liberror-perl (0.17025-1) ... Selecting previously unselected package git-man. Preparing to unpack .../4-git-man_1%3a2.17.1-1ubuntu0.1_all.deb ... Unpacking git-man (1:2.17.1-1ubuntu0.1) ... Selecting previously unselected package git. Preparing to unpack .../5-git_1%3a2.17.1-1ubuntu0.1_amd64.deb ... Unpacking git (1:2.17.1-1ubuntu0.1) ... Selecting previously unselected package ubuntu-fan. Preparing to unpack .../6-ubuntu-fan_0.12.10_all.deb ... Unpacking ubuntu-fan (0.12.10) ... Setting up git-man (1:2.17.1-1ubuntu0.1) ... Setting up docker.io (17.12.1-0ubuntu1) ... Adding group `docker' (GID 127) ... Done. Created symlink /etc/systemd/system/sockets.target.wants/docker.socket → /lib/systemd/system/docker.socket. Processing triggers for ureadahead (0.100.0-20) ... Setting up liberror-perl (0.17025-1) ... Setting up cgroupfs-mount (1.4) ... Setting up bridge-utils (1.5-15ubuntu1) ... Setting up ubuntu-fan (0.12.10) ... Created symlink /etc/systemd/system/multi-user.target.wants/ubuntu-fan.service → /lib/systemd/system/ubuntu-fan.service. Processing triggers for systemd (237-3ubuntu10) ... Processing triggers for man-db (2.8.3-2) ... Setting up git (1:2.17.1-1ubuntu0.1) ... Processing triggers for ureadahead (0.100.0-20) ...
We kunnen testen of docker werkt door bijvoorbeeld de versie op te vragen:
lbeuker@ubuntu:~$ docker --version Docker version 17.12.1-ce, build 7390fc6
Docker-Compose
Docker werkt prima voor het draaien van 1 of meerdere containers. Maar het is natuurlijk veel mooier om 1 pakket te maken van alle afhankelijkheden binnen 1 configuratie.
Dat is waar docker-compose om de hoek komt kijken. We maken 1 configuratie waarin we een losse container voor home-assistant, influxdb en grafana kunnen maken. Later kunnen we deze uitbreiden met mqtt.
Helaas is docker-compose nog niet via de package manager te installeren. Daarom moet je deze handmatig instlalleren via het volgende commando:
sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
Op dit moment is versie 1.21.2 de laatste versie. Kijk voor installatie even of er een nieuwe release is op https://github.com/docker/compose/releases
Op een verse ubuntu instalaltie is curl echter niet beschikbaar, dus eerst installeren we dat.
lbeuker@ubuntu:~$ sudo apt install curl Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: libcurl4 The following NEW packages will be installed: curl libcurl4 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. Need to get 373 kB of archives. After this operation, 1,036 kB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libcurl4 amd64 7.58.0-2ubuntu3.1 [214 kB] Get:2 http://us.archive.ubuntu.com/ubuntu bionic-updates/main amd64 curl amd64 7.58.0-2ubuntu3.1 [159 kB] Fetched 373 kB in 1s (248 kB/s) Selecting previously unselected package libcurl4:amd64. (Reading database ... 162702 files and directories currently installed.) Preparing to unpack .../libcurl4_7.58.0-2ubuntu3.1_amd64.deb ... Unpacking libcurl4:amd64 (7.58.0-2ubuntu3.1) ... Selecting previously unselected package curl. Preparing to unpack .../curl_7.58.0-2ubuntu3.1_amd64.deb ... Unpacking curl (7.58.0-2ubuntu3.1) ... Setting up libcurl4:amd64 (7.58.0-2ubuntu3.1) ... Processing triggers for libc-bin (2.27-3ubuntu1) ... Processing triggers for man-db (2.8.3-2) ... Setting up curl (7.58.0-2ubuntu3.1) ... lbeuker@ubuntu:~$
En daarna installeren we docker-compose versie 1.21.2.
sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 617 0 617 0 0 1058 0 --:--:-- --:--:-- --:--:-- 1056 100 10.3M 100 10.3M 0 0 2006k 0 0:00:05 0:00:05 --:--:-- 2752k
Nu de binary gedownload is in /usr/local/bin/docker-compose moet deze nog execute rechten krijgen zodat het gebruitk kan worden middels commando :
sudo chmod +x /usr/local/bin/docker-compose
Om te kijken of het werkt kunnen we de versie opvragen:
lbeuker@ubuntu:~$ docker-compose --version docker-compose version 1.21.2, build a133471
Nu docker-compose is geinstalleerd kunnen we verder met het inrichten van docker containers.