How to disable auto-restart

I have a container that is designed to run, do some stuff, then exit. Rancher seems to be trying to restart it forever.

I’m trying to use rancher-compose with minimal changes to the docker-compose files. Is there a flag or label I can set to tell rancher not to restart this container? Or better, only restart it if it exits with non-zero.

I tried setting “restart: no” in my compose.yml file and Rancher gave me an error:
ERRO[0000] Failed Creating : invalid restart policy false

Instead of using “restart: no”, use this label in your compose.yml.

labels:
  io.rancher.container.start_once=true

This will achieve what you are looking for. You also need to use v0.37.0. We just fixed this issue.

https://github.com/rancher/rancher/issues/1935

I had to add it to my docker-compose file like: io.rancher.container.start_once: true
but it worked great! Thanks.

BTW, the restart: no looks like it’s a bug in rancher-compose which uses docker/libcompose. I’ll follow up with a bug for that. Thanks!