MagicMirror² v2.12.0 is available! For more information about this release, check out this topic.

MM Server Mode in Docker on Raspberry



  • Good day, Ladies and Gentlemen,

    Following instructions at https://github.com/MichMich/MagicMirror and https://github.com/bastilimbach/docker-MagicMirror.

    The following steps has been done:

    1. Downloaded and flashed to SD card latest clean Raspbian Stretch with desktop (kernel version 4.14) from raspberry.org.
    2. Connected Raspberry to WiFi network.
    3. Installed Docker by executing
    curl -sSL https://get.docker.com | sh
    
    1. Get Docker autostart
    sudo systemctl enable docker
    
    1. added member to docker’s group
    sudo usermod -aG docker pi
    
    1. Reboot system to changes take place
    sudo reboot
    
    1. Downloaded container with magicmirror for raspberry
    docker pull bastilimbach/docker-magicmirror:raspberry
    
    1. Executed container start according to instructions at MM docker page:
    docker run  -d \
    	--publish 80:8080 \
    	--restart always \
    	--volume ~/magic_mirror/config:/opt/magic_mirror/config \
    	--volume ~/magic_mirror/modules:/opt/magic_mirror/modules \
    	--name magic_mirror \
    	bastilimbach/docker-magicmirror:raspberry
    
    1. Created config.js file in “/home/pi/magic_mirror/config”
    sudo nano config.js
    
    1. Edited config.js in “/home/pi/magic_mirror/config” to the following lines:

          var config = {
          	address: "0.0.0.0", // Address to listen on, can be:
          	                      // - "localhost", "127.0.0.1", "::1" to listen on loopback interface
          	                      // - another specific IPv4/6 to listen on a specific interface
          	                      // - "", "0.0.0.0", "::" to listen on any interface
          	                      // Default, when address config is left out, is "localhost"
          	port: 8080,
          	ipWhitelist: [], // Set [] to allow all IP addresses
          	                                                       // or add a specific IPv4 of 192.168.1.5 :
          	                                                       // ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.1.5"],
          	                                                       // or IPv4 range of 192.168.3.0 --> 192.168.3.15 use CIDR format :
          	                                                       // ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.3.0/28"],
          if (typeof module !== "undefined") { module.exports = config; }
          
          	language: "en",
          	timeFormat: 24,
          	units: "metric",
          
          	modules: [
          		{
          			module: "alert",
          		},
          		{
          			module: "updatenotification",
          			position: "top_bar"
          		},
          		{
          			module: "clock",
          			position: "top_left"
          		},
          		// OTHER MODULES CONFIGURATIONS DELETED HERE FOR SIMPLICITY
          	]
          
          };
          
          /*************** DO NOT EDIT THE LINE BELOW ***************/
          if (typeof module !== "undefined") {module.exports = config;}
      
    2. Reboot the system

    sudo reboot
    
    1. Checked IP addresses
    ifconfig
    
    pi@raspberrypi:/ $ ifconfig
    docker0: flags=4163  mtu 1500
            inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
            inet6 fe80::36c7:71e6:4c9c:d8d9  prefixlen 64  scopeid 0x20
            ether 02:42:50:41:f1:09  txqueuelen 0  (Ethernet)
            RX packets 13  bytes 1775 (1.7 KiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 174  bytes 40644 (39.6 KiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    eth0: flags=4099  mtu 1500
            ether b8:27:eb:fd:40:7d  txqueuelen 1000  (Ethernet)
            RX packets 0  bytes 0 (0.0 B)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 0  bytes 0 (0.0 B)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    lo: flags=73  mtu 65536
            inet 127.0.0.1  netmask 255.0.0.0
            inet6 ::1  prefixlen 128  scopeid 0x10
            loop  txqueuelen 1000  (Local Loopback)
            RX packets 0  bytes 0 (0.0 B)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 0  bytes 0 (0.0 B)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    veth0275d60: flags=4163  mtu 1500
            inet 169.254.222.123  netmask 255.255.0.0  broadcast 169.254.255.255
            inet6 fe80::6069:90ff:fec9:a75a  prefixlen 64  scopeid 0x20
            ether 62:69:90:c9:a7:5a  txqueuelen 0  (Ethernet)
            RX packets 13  bytes 1957 (1.9 KiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 350  bytes 82319 (80.3 KiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    wlan0: flags=4163  mtu 1500
            inet 192.168.43.78  netmask 255.255.255.0  broadcast 192.168.43.255
            inet6 fe80::fff4:43e5:edc6:cc9e  prefixlen 64  scopeid 0x20
            ether b8:27:eb:a8:15:28  txqueuelen 1000  (Ethernet)
            RX packets 4833  bytes 3587709 (3.4 MiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 4613  bytes 610563 (596.2 KiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    1. Tried to connect by a local Chromium to the MM server by entering the following addresses into browser’s address line:
    127.0.0.1:8080
    localhost:8080
    127.0.0.1:80
    localhost:80
    

    Got in browser:

    This site can’t be reached The connection was reset. ERR_CONNECTION_RESET
    
    1. Tried to connect from phone which is connected to the same WiFi network via browser by enetring to the Browser’s address line:
    192.168.43.78:8080
    192.168.43.78:80
    

    Result is the same,

    This site can’t be reached The connection was reset. ERR_CONNECTION_RESET
    

    For reference, list of files and folders in home/pi/magic_mirror

    pi@raspberrypi:~/magic_mirror $ ls -R
    .:
    config  modules
    
    ./config:
    config.js  config.js.sample
    
    ./modules:
    default  node_modules  README.md
    
    ./modules/default:
    alert  calendar  clock  compliments  currentweather  defaultmodules.js  helloworld  newsfeed  updatenotification  weather  weatherforecast
    
    ./modules/default/alert:
    alert.js  classie.js  modernizr.custom.js  notificationFx.js  ns-default.css  README.md  translations
    
    ./modules/default/alert/translations:
    bg.json  da.json  de.json  en.json  es.json  fr.json  hu.json  nl.json  ru.json
    
    ./modules/default/calendar:
    calendar.css  calendarfetcher.js  calendar.js  debug.js  node_helper.js  README.md  vendor
    
    ./modules/default/calendar/vendor:
    ical.js
    
    ./modules/default/calendar/vendor/ical.js:
    example.js  ical.js  index.js  LICENSE  node-ical.js  NOTICE  package.json  readme.md  test
    
    ./modules/default/calendar/vendor/ical.js/test:
    test10.ics  test11.ics  test1.ics  test2.ics  test3.ics  test4.ics  test5.ics  test6.ics  test7.ics  test8.ics  test9.ics  test.js
    
    ./modules/default/clock:
    clock.js  clock_screenshot.png  clock_styles.css  faces  README.md
    
    ./modules/default/clock/faces:
    face-001.svg  face-002.svg  face-003.svg  face-004.svg  face-005.svg  face-006.svg  face-007.svg  face-008.svg  face-009.svg  face-010.svg  face-011.svg  face-012.svg
    
    ./modules/default/compliments:
    compliments.js  compliments_screenshot.png  README.md
    
    ./modules/default/currentweather:
    currentweather.css  currentweather.js  README.md  weather_screenshot.png
    
    ./modules/default/helloworld:
    helloworld.js  helloworld.njk  README.md
    
    ./modules/default/newsfeed:
    fetcher.js  newsfeed.js  newsfeed_screenshot.png  node_helper.js  README.md  translations
    
    ./modules/default/newsfeed/translations:
    de.json  en.json  es.json  fr.json
    
    ./modules/default/updatenotification:
    node_helper.js  README.md  updatenotification.js
    
    ./modules/default/weather:
    current.njk  current.png  forecast.njk  forecast.png  providers  README.md  weather.css  weather.js  weatherobject.js  weatherprovider.js
    
    ./modules/default/weather/providers:
    darksky.js  openweathermap.js  README.md
    
    ./modules/default/weatherforecast:
    forecast_screenshot.png  README.md  weatherforecast.css  weatherforecast.js
    
    ./modules/node_modules:
    node_helper
    
    ./modules/node_modules/node_helper:
    index.js
    

    Could anyone advise what I am doing wrong here?



  • @Serge said in MM Server Mode in Docker on Raspberry:

    docker run -d
    –publish 80:8080 \

    is the container running?
    do

      docker ps
    

    because the docker run did

    docker run  -d \
    	--publish 80:8080 \
    

    the way to access is thru port 80 on the host machine…
    (no other app is trying to use port 80 already, right?, webserver)

    also,
    typically --volume doesn’t like relative file system links

    --volume ~/magic_mirror/config
    


  • @sdetweil
    thanx. I have put into container RUN command direct links

    --volume /home/pi/magic_mirror/config
    

    instead of relative ones

    --volume ~/magic_mirror/config
    

    So the RUN command looked like:

    docker run  -d \
    --publish 80:8080 \
    --restart always \
    --volume /home/pi/magic_mirror/config:/opt/magic_mirror/config \
    --volume /home/pi/magic_mirror/modules:/opt/magic_mirror/modules \
    --name magic_mirror \
    bastilimbach/docker-magicmirror:raspberry
    

    I also changed config, as I understood I should wrote port 80 there, so m,y config.js is the following:

    var config = {
        	address: "0.0.0.0", // Address to listen on, can be:
        	                      // - "localhost", "127.0.0.1", "::1" to listen on loopback interface
        	                      // - another specific IPv4/6 to listen on a specific interface
        	                      // - "", "0.0.0.0", "::" to listen on any interface
        	                      // Default, when address config is left out, is "localhost"
        	port: 80,
        	ipWhitelist: [], // Set [] to allow all IP addresses
        	                                                       // or add a specific IPv4 of 192.168.1.5 :
        	                                                       // ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.1.5"],
        	                                                       // or IPv4 range of 192.168.3.0 --> 192.168.3.15 use CIDR format :
        	                                                       // ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.3.0/28"],
        if (typeof module !== "undefined") { module.exports = config; }
        
        	language: "en",
        	timeFormat: 24,
        	units: "metric",
        
        	modules: [
        		{
        			module: "alert",
        		},
        		{
        			module: "updatenotification",
        			position: "top_bar"
        		},
        		{
        			module: "clock",
        			position: "top_left"
        		},
        		// OTHER MODULES CONFIGURATIONS DELETED HERE FOR SIMPLICITY
        	]
        
        };
        
        /*************** DO NOT EDIT THE LINE BELOW ***************/
        if (typeof module !== "undefined") {module.exports = config;}
    

    I have did once more all the steps

    Here is log from terminal

    pi@raspberrypi:/ $ docker run  -d \
    > --publish 80:8080 \
    > --restart always \
    > --volume /home/pi/magic_mirror/config:/opt/magic_mirror/config \
    > --volume /home/pi/magic_mirror/modules:/opt/magic_mirror/modules \
    > --name magic_mirror \
    > bastilimbach/docker-magicmirror:raspberry
    37638fe6e1d0dee6b3ff9973c8ec7e2c7d6b0fa71b4c095e94738b197387074e
    pi@raspberrypi:/ $ docker ps
    CONTAINER ID        IMAGE                                       COMMAND                  CREATED             STATUS              PORTS                  NAMES
    37638fe6e1d0        bastilimbach/docker-magicmirror:raspberry   "/opt/docker-entrypo…"   11 seconds ago      Up 7 seconds        0.0.0.0:80->8080/tcp   magic_mirror
    pi@raspberrypi:/ $ cd /home/pi/magic_mirror/config
    pi@raspberrypi:~/magic_mirror/config $ sudo nano config.js
    pi@raspberrypi:~/magic_mirror/config $ cd /
    pi@raspberrypi:/ $ ifconfig
    docker0: flags=4163  mtu 1500
            inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
            inet6 fe80::5b8a:414d:261e:c2f3  prefixlen 64  scopeid 0x20
            ether 02:42:cf:fa:cf:16  txqueuelen 0  (Ethernet)
            RX packets 12  bytes 1601 (1.5 KiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 170  bytes 28294 (27.6 KiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    eth0: flags=4099  mtu 1500
            ether b8:27:eb:fd:40:7d  txqueuelen 1000  (Ethernet)
            RX packets 0  bytes 0 (0.0 B)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 0  bytes 0 (0.0 B)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    lo: flags=73  mtu 65536
            inet 127.0.0.1  netmask 255.0.0.0
            inet6 ::1  prefixlen 128  scopeid 0x10
            loop  txqueuelen 1000  (Local Loopback)
            RX packets 0  bytes 0 (0.0 B)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 0  bytes 0 (0.0 B)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    veth2d3c6a7: flags=4163  mtu 1500
            inet 169.254.32.50  netmask 255.255.0.0  broadcast 169.254.255.255
            inet6 fe80::ef51:3415:a096:b052  prefixlen 64  scopeid 0x20
            ether 9a:4f:36:79:b3:72  txqueuelen 0  (Ethernet)
            RX packets 4  bytes 651 (651.0 B)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 127  bytes 19147 (18.6 KiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    wlan0: flags=4163  mtu 1500
            inet 192.168.43.78  netmask 255.255.255.0  broadcast 192.168.43.255
            inet6 fe80::fff4:43e5:edc6:cc9e  prefixlen 64  scopeid 0x20
            ether b8:27:eb:a8:15:28  txqueuelen 1000  (Ethernet)
            RX packets 13597  bytes 14840294 (14.1 MiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 11414  bytes 1524830 (1.4 MiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    pi@raspberrypi:/ $ docker ps
    CONTAINER ID        IMAGE                                       COMMAND                  CREATED              STATUS              PORTS                  NAMES
    37638fe6e1d0        bastilimbach/docker-magicmirror:raspberry   "/opt/docker-entrypo…"   About a minute ago   Up About a minute   0.0.0.0:80->8080/tcp   magic_mirror
    pi@raspberrypi:/ $ 
    
    

    When I trying to reach through
    localhost:80, 127.0.0.1:80 the browser returns

    This site can’t be reached The connection was reset.Try:
    Checking the connection
    Checking the proxy and the firewall
    ERR_CONNECTION_RESET
    

    When I am trying to reach through the address
    localhost:8080, 127.0.0.1:8080

    This site can’t be reached 127.0.0.1 refused to connect.
    Try: Checking the connection, Checking the proxy and the firewall
    ERR_CONNECTION_REFUSED
    

    So the errors are different (connection is reset and refused, respectively).
    What else should I check , @sdetweil could you please advice me?



  • @Serge ok, so you changed the magicmirror config to use port 80 inside the container
    your run command -p should be

    -p host_port:container_port
    so
    -p 80:80
    

    requests to the host port 80 are forwarded to the container port 80

    to make sure that MM in the container is working

    do

    docker inspect 37638fe6e1d0 | grep -i -m 1 \"ipaddress
    

    and look for the ip address assigned to the container
    should be

    "IPAddress": "172.17.0.???
    

    ??? is most likely 2

    then use your local system browser to go to

    http://172.17.0.???:80
    

    skipping the port forwarding


Log in to reply