Read the statement by Michael Teeuw here.
MM in Container config lost after Container Stop/Start
-
Hi all,
I sucessfully setup a container from
https://github.com/bastilimbach/docker-MagicMirror
in server mode only.
i put in my config, everything runs well.But: If i restart the container in portainer (click stop, click start), it starts, complains about config not to be found and restarts.
If i take a look into my host data at /data/compose/mounts/config, everything is still there but log complains about not finding a configI have been running a MM installation on a raspberry pi for years, so it seems to be somehow container related. I am new to virtualization things, so please forgive my ignorance.
Anyone any Ideas?
Thank you in advancelog snippet:
[14.02.2023 15:26.10.982] [ERROR] WARNING! Could not load config file. Starting with default configuration. Error found: TypeError: Cannot read properties of undefined (reading 'module') [14.02.2023 15:26.10.983] [ERROR] Whoops! There was an uncaught exception... [14.02.2023 15:26.10.986] [ERROR] TypeError: Cannot read properties of undefined (reading 'module') at /opt/magic_mirror/js/app.js:220:34 at loadConfig (/opt/magic_mirror/js/app.js:81:4) at App.start (/opt/magic_mirror/js/app.js:212:3) at Object.<anonymous> (/opt/magic_mirror/serveronly/index.js:4:5) at Module._compile (node:internal/modules/cjs/loader:1226:14) at Module._extensions..js (node:internal/modules/cjs/loader:1280:10) at Module.load (node:internal/modules/cjs/loader:1089:32) at Module._load (node:internal/modules/cjs/loader:930:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:23:47 [14.02.2023 15:26.10.986] [ERROR] MagicMirror² will not quit, but it might be a good idea to check why this happened. Maybe no internet connection? [14.02.2023 15:26.10.986] [ERROR] If you think this really is an issue, please open an issue on GitHub: https://github.com/MichMich/MagicMirror/issues
-
@sdetweil @karsten13 thanks a lot for your advice!
finally, there was only one package missingnpm install request
did the job for me.
:folded_hands_medium-light_skin_tone:
-
@asdf303 that docker image is no longer supported, I suggest moving to the one from @karsten13
-
@sdetweil thank you for your comment.
Actually, my link above is wrong. My fault. Sorry.
I am already using the imagekarsten13/magicmirror:latest.
So, any further ideas?
-
@asdf303 maybe @karsten13 will check this topic out
-
my project is documented here https://khassel.gitlab.io/magicmirror/
I don’t know the portainer setup and for further investigation we need to see
- full log
- your
docker-compose.yml
or thedocker run ...
command - full
config.js
Please remove any secrets before publishing here.
-
@karsten13 Thank you for asking.
Please find all my stuff belowAs mentioned above, it loads correctly and runs the configuration correctly on the first start.
Everything is fine.
But if the container is started/stopped in Portainer, it seems to not be able to find a correct config.js, as you can see in the log.The only way to get it running is, i stop the container, remove the stack in Portainer, then navigate to /data/compose in the host system, manually delete all the data there (i use Winscp). Then i re-install everything (including e.g. the mmm-localtransport addon) acc. to the book, modify the config.js to what you can see below.
let config = { address: "0.0.0.0", // Address to listen on, can be: port: 8080, basePath: "/", // The URL path where MagicMirror² is hosted. If you are using a Reverse proxy // you must set the sub path here. basePath must end with a / //ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1", "192.168.178.1/24"], // Set [] to allow all IP addresses ipWhitelist: [], // Set [] to allow all IP addresses useHttps: false, // Support HTTPS or not, default "false" will use HTTP httpsPrivateKey: "", // HTTPS private key path, only require when useHttps is true httpsCertificate: "", // HTTPS Certificate path, only require when useHttps is true language: "de", locale: "en-US", logLevel: ["INFO", "LOG", "WARN", "ERROR"], // Add "DEBUG" for even more logging timeFormat: 24, units: "metric", // serverOnly: true/false/"local" , // local for armv6l processors, default // starts serveronly and then starts chrome browser // false, default for all NON-armv6l devices // true, force serveronly mode, because you want to.. no UI on this device modules: [ { module: "alert", }, { module: "updatenotification", position: "top_bar" }, { module: "clock", position: "top_left", config: { displaySeconds: false, displayType: "digital", clockBold: false, // The config property is optional. // See 'Configuration options' for more information. } }, { module: "calendar", header: "Was passiert heute?", position: "top_left", config: { fade: false, timeFormat: 'absolute', dateFormat: '24', getRelative: 24, fetchInterval: 3600000, calendars: [ { // der Abfallkalender symbol: "trash", url: "webcal://XXX" }, { //private calendar symbol: "home", url: "XXX", auth: { user: "XXX", pass: "XXX", method: "basic" } } ] } }, /* { module: "compliments", position: "lower_third" },*/ { module: "weather", //aktuelles Wetter position: "top_right", //header: "aktuelles Wetter", config: { fade: false, type: "current", weatherProvider: "openweathermap", location: "XXX", locationID: "XXX", //ID from http://www.openweathermap.org/help/city_list.txt apiKey: "XXX", roundTemp: true, maxNumberOfDays: 2, } },{ module: "weather", //Vorhersage position: "top_right", header: "Vorhersage", config: { fade: false, type: "forecast", weatherProvider: "openweathermap", location: "XXX", locationID: "XXX", //ID from http://www.openweathermap.org/help/city_list.txt apiKey: "xxx", roundTemp: true, maxNumberOfDays: 4, } }, { module: "newsfeed", position: "bottom_bar", config: { feeds: [ { title: "Tagesschau", url: "https://www.tagesschau.de/xml/rss2" } ], showSourceTitle: false, showPublishDate: false, wrapTitle: false, } },,{ module: 'MMM-LocalTransport', header: 'Bus nach XXX', position: 'bottom_right', config: { api_key: 'xxxx', origin: 'xxxx', destination: 'xxxx', maximumEntries: 3, displayArrival: false, displayWalkType: 'none', updateInterval: 60, displayStationLength: -1, } }, ] }; /*************** DO NOT EDIT THE LINE BELOW ***************/ if (typeof module !== "undefined") {module.exports = config;}
Here is the docker-compose.yml, copied from your project, unchanged:
version: '3' services: magicmirror: container_name: mm image: karsten13/magicmirror:latest ports: - "8080:8080" volumes: - ../mounts/config:/opt/magic_mirror/config - ../mounts/modules:/opt/magic_mirror/modules - ../mounts/css:/opt/magic_mirror/css restart: unless-stopped command: - npm - run - server
and finally, the log after RE-starting the container.
> magicmirror@2.22.0 server > node ./serveronly [17.02.2023 13:35.40.960] [LOG] Starting MagicMirror: v2.22.0 [17.02.2023 13:35.40.962] [LOG] Loading config ... [17.02.2023 13:35.40.964] [ERROR] WARNING! Could not load config file. Starting with default configuration. Error found: TypeError: Cannot read properties of undefined (reading 'module') [17.02.2023 13:35.40.965] [ERROR] Whoops! There was an uncaught exception... [17.02.2023 13:35.40.967] [ERROR] TypeError: Cannot read properties of undefined (reading 'module') at /opt/magic_mirror/js/app.js:220:34 at loadConfig (/opt/magic_mirror/js/app.js:81:4) at App.start (/opt/magic_mirror/js/app.js:212:3) at Object.<anonymous> (/opt/magic_mirror/serveronly/index.js:4:5) at Module._compile (node:internal/modules/cjs/loader:1226:14) at Module._extensions..js (node:internal/modules/cjs/loader:1280:10) at Module.load (node:internal/modules/cjs/loader:1089:32) at Module._load (node:internal/modules/cjs/loader:930:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:23:47 [17.02.2023 13:35.40.967] [ERROR] MagicMirror² will not quit, but it might be a good idea to check why this happened. Maybe no internet connection? [17.02.2023 13:35.40.967] [ERROR] If you think this really is an issue, please open an issue on GitHub: https://github.com/MichMich/MagicMirror/issues copy default modules to host ... copy css files to host ... chown modules and config folder ... timezone is Europe/Berlin start magicmirror
-
must be something with the portainer setup.
What is strange is the order in the log file, I would expect the last lines beginning with
copy default modules to host ...
at the top.One thing you can try is to change
restart: unless-stopped
torestart: never
in thedocker-compose.yml
, may 2 containers are started when portainer stops the one running. -
@karsten13 thank you, i will try next time, will take 2…3 days, maybe
-
update: if the module: ‘MMM-LocalTransport’, module is disabled, it works.
Strange thing:- the module works on my raspi electron installation.
- it does not in the container.
I will keep you updated.
-
this module is not really maintained, it relies on an outdated dependency (
request
) which was removed from mm core a long time ago.If it runs on your pi the mm installation there is very old or you installed
request
manually. See this topic for more info.