Run Once...How?

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’?



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

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


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… :stuck_out_tongue:

Good you found a working solution, though :wink:

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.

Ah, thank you @denise, that makes sense.