We saw in the previous article how to install and Docker Toolbox for test automation simply on Mac and PC software. Now that Docker is officially supported by the Raspberry Foundation, it is very easy to install. We will take the opportunity to test some home automation software. To achieve this article, I followed the tutorial Alex Ellis .
Set up the Raspberry Pi
Hardware and software
To work Docker properly, it is recommended to use a model B 2/3 or a Pi Zero.
Download Raspbian Jessie Lite here. The Lite version is sufficient to run Docker. It includes no graphic interface.
If you do not yet download etcher from here.
Prepare the SD board
You are on Mac or PC, the easiest is to use etch to prepare the SD board.
Set up the Raspberry Pi 3 (WiFi, keyboard, language…)
Now that we have a Raspberry configured correctly, it remains to install Docker. One line will be necessary.
curl -sSL get.docker.com | sh
Be patient, it takes already download Docker then install it on the Raspberry. Allow about 10 minutes. If all went well, you should have the information report.
Check that Docker works correctly by typing the following command in the Terminal.
Now we allow Docker to start automatically at launch of the Raspberry.
sudo systemctl enable docker
If you want to add other users to the Pi, run this command
sudo usermod -aG docker pi
We could manually run the deamon Docker but I encountered problems during my testing. I you Council so to do a reboot.
That is, Docker is ready.
Find images rpi to install
You can find images for Raspberry Docker on github, but the easiest is to go to the hub official.
The Raspberry being based on an ARM processor, images must include sources adapted for this one. To more easily identify them, the images are pré-fixées rpi (or armhf). Enter simply rpi in the search field. There are slightly more than 2000 at the time of the writing of this article. It’s time to see how it works on a concrete example. We will install and test 2 software automation, Jeedom and Domoticz.
Test Jeedom with Docker
The same on Mac and PC, we’ll install an image of mysql as well as a picture of Jeedom adapted to the Raspberry. I followed the instructions of sbeuzit available here.
We begin by installing image rpi-jeedom-data to store the data in the mysql database permanently.
sudo docker pull sbeuzit/rpi-jeedom-data sudo docker run --name jeedom-data sbeuzit/rpi-jeedom-data
And then we install the mysql database. Replace MOT_DE_PASSE_MYSQL with your password (you will need to configure the connection to the database in Jeedom).
sudo docker pull hypriot/rpi-mysql sudo docker run --name jeedom-mysql -e MYSQL_ROOT_PASSWORD=MYSQL_PWD --volumes-from jeedom-data -d hypriot/rpi-mysql
Finally installed the Jeedom container. Before you run the command, change the Mac address of your Raspberry. You can get it easily with the ifconfig command. It is located on right side of HWaddr .
sudo docker run -d --link jeedom-mysql:mysql --name jeedom --mac-address="xx:xx:xx:xx:xx:xx" -p 80:80 -p 8083:8083 -p 443:443 sbeuzit/rpi-jeedom
If you want all these containers that start automatically at startup of the Pi, add the option –restart=always to each run docker.
Before going any further, check that all the containers are well run with the command sudo docker ps -a. The -a option to view in detail the list of container and check the status and ID.
docker inspect ID_CONTAINER
In the NetworkSettings section, you will find the ip address of the database to the IPAddress key.
docker exec-ti jeedom bash then ping jeedom-mysql
Ctrl + C to stop the ping. Exit out of the container.
We can now open a browser and enter the following address in the url
You reach the page to connect to the mysql database. Fill in the fields according to your configuration:
- Database hostname : replace localhost with the ip address of the previously found mysql machine
- Database port : change nothing (except modification on your part)
- Database username : let root
- Database password : the one you chose for the key MYSQL_ROOT_PASSWORD
- Database name : jeedom
Install the image of Domoticz for Raspberry. This image installs and works fine.
Then set up the command docker run that matches your configuration
docker run -v /etc/localtime:/etc/localtime -v /SOMEPATH/domoticz.db:/root/domoticz/domoticz.db:rw -p 8080:8080 --name domoticz --restart=always -d allardvdb/rpi-domoticz
Some explanations (in detail here):
docker run -d rpi/allardvdb-domoticz[:thedockerruncommandusual
- –restart=always : allows you to restart the container after a restart of the Raspberry (optional)
-v /etc/localtime:/etc/localtime: use the time of the host (optional)
-device=/dev/ttyUSB0: exposes to the container the device connect on the USB/dev/ttyUSB0 of the raspberry (optional)
-v CHEMIN/domoticz.db:/root/domoticz/domoticz.db: to use a backup of an old Domoticz (optional)
-p 8080:8080exposes port 8080 of the container on port 8080 of the Raspberry (be careful not to use a port already used by something else)
for this article gives
docker run -p 8080:8080 --name domoticz --restart=always -d allardvdb/rpi-domoticz
Now open a browser and enter
And this is Domoticz is perfectly functional. You can see by the way that Jeedom and Domoticz work (without doing anything!) on the same Raspberry with no problems. The magic of Docker.
Some tips for using Docker
Here’s to loose some very useful commands for easily use Docker with home automation software.
|docker ps-a||allows you to list the containers and know their status|
|docker run||created a container||–restart=always: allows you to launch the container automatically on startup. Practice for a home automation server!–device: to expose a device connected to the Raspberry and use it in the container|
|docker start name||starts the container|
|docker stop name||stop the container|
|docker rm name||delete the container (and data)|
|docker inspect name||allows to retrieve information , for example the ip address of a mysql database|