Perhaps change restart policy to 'always'
steinauf85 opened this issue · 3 comments
Just had a situation where I was locked out of Portainer after a reboot because I had stopped all containers before rebooting and was using the "unless-stopped" policy. In hindsight, it makes perfect sense and did exactly as it was instructed, but unfortunately my setup had become too dependent on the cloudflare tunnel. I had setup OAuth on Portainer and had hidden the internal authentication prompt, and since OAuth used my tunnel domain which was broken without the cloudflared container running, and the default password prompt wasn't available, I thought I was stuck.
Fortunately the internal authentication for Portainer is just hidden and there's a URL to log back in using the original user's password, so I was able to get back in and restart my containers, but this wouldn't have happened if I had used the "always" restart policy. I have since gone in and updated that policy for any other mission critical containers that can cause havoc when down. If I really want to keep these containers stopped after a restart then I'll just stop the stack in Portainer which is unaffected by the containers restart policy. Not sure if someone using the stock docker-compose instead of Portainer would have that luxury, and for them perhaps "unless-stopped" makes sense.
Lastly, perhaps I shouldn't bother stopping containers before a reboot or shutdown? If I hadn't done that step, I wouldn't have gotten myself into this situation.
Please close this issue.
restart: always
should be defined in the docker run command or in the docker-compose file and is not defined in the Dockerfile
Please close this issue.
restart: always
should be defined in the docker run command or in the docker-compose file and is not defined in the Dockerfile
My intention was to modify the sample compose file in the readme, not to alter the dockerfile.
I understand the intent here though as you note in your last line, that scenario could have been avoided by not stopping the containers before rebooting, as the service shutdown sequence would have done that itself. Setting the restart policy to unless-stopped
avoids some nasty and unwelcome situations where a container is intentionally stopped and then crops back up on a daemon or system restart.
I have compromised though, and added a note about it here 05c4658
Hopefully that helps.