Consider the following scenario:
- I have a stack which consists of multiple services
- One of those services comprises a container image which needs to be run twice: once to do a DB migration, once to run a server daemon.
- The DB migration is a command which runs once, then the container shuts down.
Using rancher-compose, I can kind of get this working, but creating two instances of the service, one of which runs the daemon, and one which uses as a command
option to run the migration.
The problem is that as soon as that migration service dies, Rancher’s clever auto-scaling keeps starting it up again. I can get around this for the moment by stopping the service completely once it’s run once, but that’s far from ideal. The docker-compose option restart: "no"
has no effect.
I’m wondering if there’s a simple way for me to start a service and only run it once, preventing it from restarting.
Ultimately, I could around this by creating a new custom image which does the migration and startup all in one go, but thought I’d ask incase there was something obvious which would save me that effort at the moment.