I have been wanting to build a smart mirror for some time. As it turns out, I happen to have a raspberry pi, old monitor and a few other odds and ends laying around in the office. All I needed was to come across this awesome project call MagicMirror to give me that spark. I decided to use Docker to install MagicMirror so I can test the configurations.
What is MagicMirror?
MagicMirror² is an open source modular smart mirror platform. With a growing list of installable modules, the MagicMirror² allows you to convert your hallway or bathroom mirror into your personal assistant.
Now that we have that out of the way, I was looking for a way to test this out in a docker container. I figured that I would be able to install it on docker and do some testing before I dove into setting up the pi. Thanks to another contributor to the project, this was made very easy.
Install Docker
For this tutorial we will be installing Docker on CentOS 7. If you need instructions for installing Docker on Ubuntu or want to learn more about it, please read our Getting Started with Docker in Linux article.
1) Enable the docker-ce repo
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
2) Install docker-ce
sudo yum install docker-ce
3) Start the docker service
sudo systemctl start docker
4) Enable the docker server to start it on boot
sudo systemctl enable docker
5) Add your user to the docker group
sudo usermod -aG docker $USER
Pull the MagicMirror Image and Run the Install
docker run -d --publish 8181:8080 --restart=always --volume /home/docker/magic_mirror/css/custom.css:/opt/magic_mirror/css/custom.css --volume /home/docker/magic_mirror/config:/opt/magic_mirror/config --volume /home/docker/magic_mirror/modules:/opt/magic_mirror/modules --name magic_mirror bastilimbach/docker-magicmirror
Let’s break these options down.
docker run -d (Tells the system to run the image in a container in the background.)
–publish 8181:8080 (This maps port 8181 on the host system to the default port 8080 that MagicMirror runs on in the container. This will allow us to access the MagicMirror using HOST-IP:8181)
–restart=always (This tells the container to run automatically if docker is started)
Then we create 3 volumes, this will allow us to save persistent data on the host hard drive and edit the config and modules for testing. If we rebuild, the config will not get blown away since it is stored outside of the container. The first path is the local path to store the data, the second path is the path that is mounted in the container.
- First Volume: /home/docker/magic_mirror/css/custom.css:/opt/magic_mirror/css/custom.css
- Second Volume: /home/docker/magic_mirror/config:/opt/magic_mirror/config
- Third Volume: /home/docker/magic_mirror/modules:/opt/magic_mirror/modules
–name magic_mirror (This gives the container a friendly name that can be used for starting/stopping the container)
The last part (bastilimbach/docker-magicmirror) tells the docker command which image to use to build the container.
Open the firewall to allow access to your new install
iptables -I INPUT -p tcp --dport 8181 -j ACCEPT
firewall-cmd --permanent --add-port=8181/tcp
Edit the Configuration and Let's Roll
Copy the sample config to the new running config.
cd /home/docker/magic_mirror/config/
cp config.js.sample config.js
That’s it, your Magic Mirror should be up and running. Open a browser on any system and point it to your host IP address and port 8181 like this:
http://host-ip:8181
Suggested Edits
People in the US will probably want to use imperial instead of metric units as well the English language and a 12 hour clock format. To enable these globally, open the config.js file in your favorite editor and edit the following lines:
language: "en",
timeFormat: 12,
units: "imperial",
That’s it, now you can play and set up the mirror the way you like.
External Resources
You can find a list of the default modules here:
https://github.com/MichMich/MagicMirror/tree/master/modules/default
Here is a list of third party modules:https://github.com/MichMich/MagicMirror/wiki/3rd-party-modules
You can find some inspiration here:
https://forum.magicmirror.builders/category/12/show-your-mirror
Leave a Reply Cancel reply
This site uses Akismet to reduce spam. Learn how your comment data is processed.
9 Comments
Join Our Newsletter
Categories
- Bash Scripting (17)
- Basic Commands (50)
- Featured (7)
- Just for Fun (5)
- Linux Quick Tips (98)
- Linux Tutorials (65)
- Miscellaneous (15)
- Network Tools (6)
- Reviews (2)
- Security (32)
What really annoys me about these tutorials is that they're simply using an image they basically know nothing about or if they do, they mention nothing - that is really trustworthy or whatever. What happens if the user decides all of a sudden to update the image with malware or what not?
This is called lazy.
Hi, gret tutorial! Just a question: how I can connect to this "magicmirror" ? Suppose that my centos box is on any vps server and I want to connect to this with a raspberry device from my home or office.
Thanks in advance.
It should work the same way. If you install docker on your VPS, then install magicmirror container, you should be able to connect to it with the VPS IP address. You may have to open port 8181 on the firewall (or ask your VPS hosting if they allow it).
Ok sure, but I understand: from anorher system, for example a rpi box; how I can setup it that at every boot, it automatically open a browser and point to the vps ip/port
Fabrizio, I am glad you are finding our article useful. What you are asking is outside the scope of this article, but maybe I can help.
Check this thread at the raspberry pi forums. They discuss exactly what you are trying to do. Read the whole thread because the first option provided is not the best.
https://www.raspberrypi.org/forums/viewtopic.php?t=8298
Be sure to come back and let us know how it worked out. If you need further help I will see what I can do.
Sure! But I'm Curios.. how do you see your mirror? You dont'use any browser?
I do use a browser. I run magic mirror directly on my raspberry pi and when it boots it loads the browser in kiosk mode automatically.
So I can use the same method to run rpi in kiosk mode.. how do you realize it?
I am not sure what you are asking me. But yes, you can run the browser in kiosk mode on raspbian.