Erisa / cloudflared-docker

Simple Alpine-built scratch-runtime Dockerfile for cloudflared, with support for multiple architectures.
https://hub.docker.com/r/erisamoe/cloudflared
Other
158 stars 22 forks source link

Perhaps change restart policy to 'always' #15

Closed steinauf85 closed 9 months ago

steinauf85 commented 1 year ago

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.

Letgamer commented 9 months ago

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

steinauf85 commented 9 months ago

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.

Erisa commented 9 months ago

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 https://github.com/Erisa/cloudflared-docker/commit/05c465808e35210684ce31a0efb2a18f2d1ce4d0 Hopefully that helps.