bastilimbach / docker-MagicMirror

Docker image for the Magic Mirror 2 project by Michael Teeuw.
https://hub.docker.com/r/bastilimbach/docker-magicmirror/
MIT License
185 stars 54 forks source link

Port 80 in use #11

Closed xbmcnut closed 6 years ago

xbmcnut commented 6 years ago

Hi there. Trying to install this on a Synology NAS and get the following error. Error response from daemon: driver failed programming external connectivity on endpoint magic_mirror (1f15ec0475348aa25175fa1c12f19e5306a2e6df810d37719574cc6fab0ae2bf): Error starting userland proxy: listen tcp 0.0.0.0:80: bind: address already in use.

Very difficult to shift port 80 on the NAS. Is there a workaround?

bastilimbach commented 6 years ago

Did you try changing --publish 80:8080 to some other port, like: --publish 3000:8080?

xbmcnut commented 6 years ago

Thanks for the fast response. I did this --publish 9080:9080 \ and changed the .js file to this:

    var config = {
    address: "",
    port: 9080,
    ipWhitelist: []
}

if (typeof module !== "undefined") { module.exports = config; }
xbmcnut commented 6 years ago

I use 8080 on my NAS for my UniFi controller.

xbmcnut commented 6 years ago

Changed it to this now and restarted, still no access.

image

bastilimbach commented 6 years ago

I did test this myself and it worked on my end. Could you please compare your config files with mine?

// config.js

var config = {
  address: "",
  port: 9080,
  ipWhitelist: []
}

if (typeof module !== "undefined") { module.exports = config; }
# docker command

docker run  -d \
    --publish 9080:9080 \
    --restart always \
    --volume ~/Desktop/magic_mirror/config:/opt/magic_mirror/config \
    --volume ~/Desktop/magic_mirror/modules:/opt/magic_mirror/modules \
    --name magic_mirror \
    bastilimbach/docker-magicmirror

Could you try to adjust you config file and then remove the container with docker rm magic_mirror and run it again with the above command? Maybe somethings isn't working with docker restart.

bastilimbach commented 6 years ago

Btw could you check, that port 9080 isn't used: netstat -an | grep 9080

bastilimbach commented 6 years ago

Also please double check that you added the desired port to your Synology Firewall.

xbmcnut commented 6 years ago

Ah, didn't do the firewall as haven't needed to for any other container (MQTT, Home Assistant, UniFi). I tried your exact config and although there are no errors in the Docker log file, I can't access http://nasip:9080

xbmcnut commented 6 years ago

tcp6 0 0 :::9080 :::* LISTEN

xbmcnut commented 6 years ago

NAS firewall is off

xbmcnut commented 6 years ago

I stopped the container, removed it, modded the .js file with your code below then start a new container with port 9080 and still have no access.

xbmcnut commented 6 years ago

With the Docker container removed, netstat reports no activity on 9080.

xbmcnut commented 6 years ago

Midnight here in NZ so I'll pick this up tomorrow night. Thanks for your help. Very much appreciated, 👍

bastilimbach commented 6 years ago

So the Error response from daemon [...] address already in use is gone right? I think I know where the issue comes from. Some users reported, that the ipWhitelist: [] option inside the config.js file doesn't allow all IPs. This is a bug with Magic Mirror. Could you please try adding this:

ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1", "0.0.0.0", "::ffff:0.0.0.0"]

This forum post might be interesting: ipWhitelist HowTo

xbmcnut commented 6 years ago

Buggar. Was very hopeful that would work but sadly no.

var config = {
  address: "",
  port: 9080,
  ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1", "0.0.0.0"]
}

if (typeof module !== "undefined") { module.exports = config; }

    language: "en",
    timeFormat: 24,
    units: "metric",
xbmcnut commented 6 years ago

This is the Synology Docker log which is odd as it's reporting the port as 8080.

018-07-23 11:53:58 | stdout | Ready to go! Please point your browser to: http://localhost:8080
-- | -- | --
2018-07-23 11:53:58 | stdout |  
2018-07-23 11:53:58 | stdout | Sockets connected & modules started ...
2018-07-23 11:53:58 | stdout | Connecting socket for: updatenotification
2018-07-23 11:53:58 | stdout | Server started ...
2018-07-23 11:53:58 | stdout | Starting server on port 8080 ...
2018-07-23 11:53:58 | stdout | All module helpers loaded.
2018-07-23 11:53:58 | stdout | No helper found for module: helloworld.
2018-07-23 11:53:58 | stdout | Module helper loaded: updatenotification
2018-07-23 11:53:58 | stdout | Initializing new module helper ...
2018-07-23 11:53:58 | stdout | Loading module helpers ...
2018-07-23 11:53:58 | stderr | WARNING! Could not validate config file. Please correct syntax errors. Starting with default configuration.
2018-07-23 11:53:58 | stdout | Loading config ...
2018-07-23 11:53:58 | stdout | Starting MagicMirror: v2.4.1
bastilimbach commented 6 years ago

Oh wait! Look:

2018-07-23 11:53:58 | stderr | WARNING! Could not validate config file. Please correct syntax errors. Starting with default configuration.

Your config is invalid. Could you post your whole config?

xbmcnut commented 6 years ago

Just working on that now as just noticed that error too.

xbmcnut commented 6 years ago

My apologies Sebastian, seems it was a syntax error. I did not notice that this code below was already at the bottom the of config file:

/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {module.exports = config;}

I now get this which is a step in the right direction.

This device is not allowed to access your mirror. Please check your config.js or config.js.sample to change this.

Thank you!!

xbmcnut commented 6 years ago

Changed ipWhitelist: [], // Set [] to allow all IP addresses and bam!

image

xbmcnut commented 6 years ago

Thank you again for all your help. I think I'll pop up a blog post on that. Nite nite

bastilimbach commented 6 years ago

Nice! If you publish a blog post about this, let me know! Would love to read it, as I'm also considering buying a Synology NAS.

Good night, sexy! 😂

xbmcnut commented 6 years ago

😂 Nice. Unfortunately, I'm having to delay the blog post/YouTube video as I can't quite get the docker version of MM to play nicely with MMM-homeassistant-sensors or MMM-xiaomi. I had a similar issue with my Docker version of Hass.io when I installed the Node-Red add-on and the Xiaomi Node as the node could never 'see' my Xiaomi gateway. The two aforementioned MM modules don't seem to be able to 'see' either my Xiaomi gateway or Home Assistant but MMM-HASS does work albeit intermittently and with not all sensor data being reported. As a lot of these modules have very limited success with posting issues, it is quite difficult to figure out where the problem lies.

I was hopeful that MM could become my ulimate HA wall mounted dashboard using a large tablet and a kiosk app to run the browser fullscreen but back to the drawing board. Without deep integration into either Xiaomi and/or Home Assistant, it is not that useful or wife friendly.

I'll spark up my 2yr old Pi based version of MM and update everything and see if that gives me more joy.

If you have any thoughts on my 'discovery' issue under Docker, let me know.

bastilimbach commented 6 years ago

Are the services you try to connect with also running in Docker containers? If so you need to make sure, that you create a shared network which the desired containers use. https://docs.docker.com/network/bridge/#manage-a-user-defined-bridge

xbmcnut commented 6 years ago

Thanks and apologies for the delay. I've built a Pi version and will try to get HA working in that first. I have the current container in bridge mode already.