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. 

Project Home

Git Repo

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

Using iptables:

iptables -I INPUT -p tcp --dport 8181 -j ACCEPT

Using Firewalld:

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:


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:

Here is a list of third party modules:https://github.com/MichMich/MagicMirror/wiki/3rd-party-modules

You can find some inspiration here: