# Aanhoudende configuratie van restart-policy

**URL:** https://meta.discourse.org/t/persistent-configuration-of-restart-policy/213715
**Category:** Self-hosting
**Created:** [3 januari 2022 om 13:32 UTC](https://meta.discourse.org/t/persistent-configuration-of-restart-policy/213715 "2022-01-03T13:32:19Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![svogt](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/svogt/32/102199_2.png) [@svogt](https://meta.discourse.org/u/svogt)
#### Post date: [3 januari 2022 om 13:32 UTC](https://meta.discourse.org/t/persistent-configuration-of-restart-policy/213715/1 "2022-01-03T13:32:19Z")

</div>

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

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [3 januari 2022 om 19:56 UTC](https://meta.discourse.org/t/persistent-configuration-of-restart-policy/213715/2 "2022-01-03T19:56:56Z")

</div>

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:

> <https://stackoverflow.com/questions/26852321/docker-add-a-restart-policy-to-a-container-that-was-already-created>

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

---

<div class="post-metadata">

### Author: ![svogt](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/svogt/32/102199_2.png) [@svogt](https://meta.discourse.org/u/svogt)
#### Post date: [3 januari 2022 om 20:44 UTC](https://meta.discourse.org/t/persistent-configuration-of-restart-policy/213715/3 "2022-01-03T20:44:24Z")

</div>

Yeah, I know that 😉 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 😉

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [3 januari 2022 om 20:47 UTC](https://meta.discourse.org/t/persistent-configuration-of-restart-policy/213715/4 "2022-01-03T20:47:24Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![svogt](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/svogt/32/102199_2.png) [@svogt](https://meta.discourse.org/u/svogt)
#### Post date: [3 januari 2022 om 20:53 UTC](https://meta.discourse.org/t/persistent-configuration-of-restart-policy/213715/5 "2022-01-03T20:53:31Z")

</div>

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. 🙂 Will just do the docker update (or if I keep forgetting it too often do the docker update via cron every 5 min 😉 )
