# Run Once...How?

**URL:** <https://forums.suse.com/t/run-once-how/798>\
**Category:** Rancher 1.x\
**Created:** [October 28, 2015, 10:49am UTC](https://forums.suse.com/t/run-once-how/798 "2015-10-28T10:49:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rucknar](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/rucknar/32/107_2.png) [@Rucknar](https://forums.suse.com/u/Rucknar)\
**Post date:** [October 28, 2015, 10:49am UTC](https://forums.suse.com/t/run-once-how/798/1 "2015-10-28T10:49:26Z")

</div>

In the rancher world, how do we best handle short lived processes? For example, we have a ElasticSearch ‘cleanup’ container, we want to run as and when we require and it runs for a short period then exits. Another example is a test harness we wish to run on occasion against a service we are developing.

This is the desired behaviour but rancher believes it to of failed and issues a restart, is there a suitable way we can ask rancher to handle a service as ‘run once’?

Thanks

Ed

---

<div class="post-metadata">

**Author:** ![kaos](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/kaos/32/38_2.png) [@kaos](https://forums.suse.com/u/kaos)\
**Post date:** [October 28, 2015, 10:54am UTC](https://forums.suse.com/t/run-once-how/798/2 "2015-10-28T10:54:12Z")

</div>

Auto restart never ought to work… (available under advanced options, command tab, when you add a service in the UI).

![](https://us1.discourse-cdn.com/flex022/uploads/suse/original/1X/623c1e827e02ea401ad2a4aa6e3f1749018dd7b1.png)

---

<div class="post-metadata">

**Author:** ![Rucknar](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/rucknar/32/107_2.png) [@Rucknar](https://forums.suse.com/u/Rucknar)\
**Post date:** [October 28, 2015, 10:55am UTC](https://forums.suse.com/t/run-once-how/798/3 "2015-10-28T10:55:34Z")

</div>

That just handles restarts under host failures etc. Funnily enough i found this from Denise in another post which should do the trick!

````auto
io.rancher.container.start_once=true```
````

---

<div class="post-metadata">

**Author:** ![kaos](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/kaos/32/38_2.png) [@kaos](https://forums.suse.com/u/kaos)\
**Post date:** [October 28, 2015, 11:00am UTC](https://forums.suse.com/t/run-once-how/798/4 "2015-10-28T11:00:45Z")

</div>

Oh… hmm… right. I see that the auto restart maps to the docker run option `--restart`, but I think that rancher ought to adhere to that restart policy, rather than to add its own on top of it. Unless I’m missing the point, which could probably be the case here… 😛

Good you found a working solution, though 😉

---

<div class="post-metadata">

**Author:** ![denise](https://avatars.discourse-cdn.com/v4/letter/d/82dd89/32.png) [@denise](https://forums.suse.com/u/denise)\
**Post date:** [October 30, 2015, 6:52am UTC](https://forums.suse.com/t/run-once-how/798/5 "2015-10-30T06:52:46Z")

</div>

We are adhering to the restart policy. It’s just the concept of a service with a scale of 1.

If you have a scale of 1, that means the service will always have 1 running container. We aren’t restarting a container when the scale is 1. We are just trying to get 1 container running in the service.

In @Rucknar’s case, he was looking for a data container that would run once and stop (and remain stopped with no running containers in the service), which is the exact use case for the label `io.rancher.container.start_once=true`.

---

<div class="post-metadata">

**Author:** ![kaos](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/kaos/32/38_2.png) [@kaos](https://forums.suse.com/u/kaos)\
**Post date:** [October 30, 2015, 1:02pm UTC](https://forums.suse.com/t/run-once-how/798/6 "2015-10-30T13:02:03Z")

</div>

Ah, thank you @denise, that makes sense.
