gcgarner / IOTstack

docker stack for getting started on IOT on the Raspberry PI
GNU General Public License v3.0
1.5k stars 578 forks source link

After reboot the containers won't start automatically #150

Open Spunckie opened 4 years ago

Spunckie commented 4 years ago

Only the Container 'Portainer' starts after reboot automatically. The other Containers art stopped. I tried to change the restart-option from 'unless-stopped' to always, but unfortunately nothing changed. Any ideas?

JDRBoston commented 4 years ago

I'm having a similar problem. But, although influxDB, grafan, portainer, moquitto, and iotstack_nodered restart, I cannot get telegraf to restart. I note that the IOTStack docker-compose.yml file did not indicate a "restart" option. So I used nano to add "restart: unless-stopped". This did not cause telegraf to restart. I saw on some docker - telegraf boards that they indicated "restart: always" so I tried that as well. No joy - the other containers automatically started on reboot but telegraf did not. After reboot, I can restart the container and telegraf does its job. But it would be great to have it automatically run on restart... Any ideas?

Paraphraser commented 4 years ago

First off, gcgarner/IOTstack (this repo) is dormant so you might have more luck re-asking this question at the forked version. Second, maybe it needs a "depends_on: - influxdb". See this gist. I haven't tried it so I can't say whether that's the solution. I assume you ran docker-compose up -d after adding the "unless stopped"? Have you found the telegraf log? What does it say?

Paraphraser commented 4 years ago

Thinking about this some more, if "unless stopped" is in effect then even if telegraf fires up, can't find influxdb and restarts, it should just keep restarting until influxdb is there. What does docker ps have to say about the telegraf container?

Maybe post the docker-compose.yml snippet you are using for telegraf.

I also remember Graham Garner saying something about needing to use an explicit "user 0" statement. In my own digging around it has always seemed to me that containers run as root unless a "user" statement is present and its value is non-zero but maybe Graham found other cases like Mosquitto where you have to work quite hard to defeat its auto-downgrade to user 1883.

If telegraf wants to run as something other than root then maybe that's leading to a permissions issue. But why telegraf would start but not restart if that were the case is something I don't know.

JDRBoston commented 4 years ago

Phil, thank you for your quick and thoughtful response! After I posted the question, I did find the forked version of IOTstack. It looks like there continues to be work on it - before we troubleshoot this problem with telegraf not restarting, should I remove the previous IOTstack version, download the current one, and see if the problem persists? If you don't think that that might solve the problem, then I'll work with my current version, pull the telegraf log and copy the docker ps output and share them with you. Thank you, again! Jay


From: Phill notifications@github.com Sent: Sunday, June 28, 2020 9:14 PM To: gcgarner/IOTstack IOTstack@noreply.github.com Cc: JDRBoston jdrobertsjr@hotmail.com; Comment comment@noreply.github.com Subject: Re: [gcgarner/IOTstack] After reboot the containers won't start automatically (#150)

Thinking about this some more, if "unless stopped" is in effect then even if telegraf fires up, can't find influxdb and restarts, it should just keep restarting until influxdb is there. What does docker ps have to say about the telegraf container?

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/gcgarner/IOTstack/issues/150#issuecomment-650852650, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AQDPLYLBKGIT2NL6SWDIXSDRY7TFZANCNFSM4LCNWMBA.

JDRBoston commented 4 years ago

Thank you! Adding the -d flag after docker-compose up did the trick; now telegraf restarts after reboot and power outage. Greatly appreciate your help! - Jay

Paraphraser commented 4 years ago

Ah, yes, the "-d" meaning "detach" or "run in the background" as distinct from running with the current shell process (the login). You reboot, that implies a logout, the logout implies a termination of child processes, no restart after the reboot.

There is no need to clobber your current IOTstack and redownload to switch to the new repo. Just follow these instructions. That's what I did. BUT I also (a) took a backup, and (b) made a copies of anything I thought I might need like docker-compose.yml and files I had changed in the services directory. After re-running the menu and doing a "pull full service from template" I then worked through to see what had changed and what tailoring I needed to put back. I think docker-compose.yml didn't need any fixes but I had to re-edit some of the changes in services.

I also removed both Node-Red images, did an explicit docker-compose pull and then brought the stack up with docker-compose up --build -d. Node-Red is the only container I have that uses a Dockerfile but you might have to manually remove image pairs for anything else that is built using a local Dockerfile.

I hope that makes sense.

JDRBoston commented 4 years ago

It does, Phil. Thank you for all the advice! Best wishes, Jay


From: Phill notifications@github.com Sent: Monday, June 29, 2020 7:03 PM To: gcgarner/IOTstack IOTstack@noreply.github.com Cc: JDRBoston jdrobertsjr@hotmail.com; Comment comment@noreply.github.com Subject: Re: [gcgarner/IOTstack] After reboot the containers won't start automatically (#150)

Ah, yes, the "-d" meaning "detach" or "run in the background" as distinct from running with the current shell process (the login). You reboot, that implies a logout, the logout implies a termination of child processes, no restart after the reboot.

There is no need to clobber your current IOTstack and redownload to switch to the new repo. Just follow these instructionshttps://github.com/SensorsIot/IOTstack#migrating-from-the-old-repo. That's what I did. BUT I also (a) took a backup, and (b) made a copies of anything I thought I might need like docker-compose.yml and files I had changed in the services directory. After re-running the menu and doing a "pull full service from template" I then worked through to see what had changed and what tailoring I needed to put back. I think docker-compose.yml didn't need any fixes but I had to re-edit some of the changes in services.

I also removed both Node-Red images, did an explicit docker-compose pull and then brought the stack up with docker-compose up --build -d. Node-Red is the only container I have that uses a Dockerfile but you might have to manually remove image pairs for anything else that is built using a local Dockerfile.

I hope that makes sense.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/gcgarner/IOTstack/issues/150#issuecomment-651413292, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AQDPLYNHTJEG7CFPPRT3AA3RZEMUNANCNFSM4LCNWMBA.