Persistent configuration of restart-policy

Hi,

I’m using the discourse_docker repo with the launcher script to run an internal Discourse instance. I’d like to persistently change the restart policy from always to unless-stopped to be able to keep the docker containers stopped when doing OS upgrades / reboots.

I can see that the restart policy is a variable in the launcher script but how to best keep this setting when a new container is built? It should work via both “launcher rebuild” as well as using the docker_manager via /admin/upgrade

Thanks in advance,
Greetings
.sascha

1 Like

I don’t remember anyone else ever asking this, and I don’t see an obvious way. I think your best bet is do to a

  ./launcher destroy app

if you want it to stay stopped and start it again with

  ./launcher start app

This will destroy the container, so any changes you’ve made inside it (like upgrades from docker_manager) will be destroyed.

Oh, but here’s this:

tl;dr: do a docker update --restart=unless-stopped app after each rebuild.

2 Likes

Yeah, I know that :wink: The docker update is what I’m currently doing. But I’m afraid I’m going to forget it at some of the next rebuilds. So hence the question how to make it persistent.
Another option would be to just edit the launcher script and hope for not too many rebase conflicts upon pull :wink:

The only time I’ve had trouble wtih restarts after a boot is if I switched from app.yml to web_only.yml and forgot to destroy the app container. I regularly do docker upgrades and reboots without any trouble with the autostarts. FWIW, I haven’t seen anyone else concerned about this in the past 5 years. Unless you’ve got some stuff at play that I don’t know about, maybe just don’t worry about it?

Well today the issue was that I wanted to do a fresh install as I had some weird 2.4.0-betaXYZ which wouldn’t update on it’s own. I did a test on another VM with a clean install and restoring the backup to 2.7.12 which worked perfectly (also split the data container into redis and postgres).

Now the main server was still running an old Ubuntu and old Docker, so I wanted to

  1. take a backup
  2. shutdown Discourse
  3. do OS upgrade shenanigans without worrying about Discourse including several reboots
  4. Do a fresh installation
  5. Restore the backup

I just wanted to keep the containers off and do not delete them right away, as I wasn’t sure anymore if I needed anything from them which I might had forgotten during my test. And I just thought, hey, unless-stopped is to me the perfect restart policy as it makes sure the containers come up after reboot automatically just unless you manually stop them. Usually exactly what I want, so i thought why not trying to make that permanent.

It’s not a big deal if it’s not possible. :slight_smile: Will just do the docker update (or if I keep forgetting it too often do the docker update via cron every 5 min :wink: )