Using labels to start a stopped container? #42
Replies: 4 comments 2 replies
-
Glad you've found some use for Chadburn, but I'm not sure I'm going to be of much help today. My brain is a bit foggy, which happens frequently these days! Let's see if I have this right: You have a task that needs to be performed periodically, but the target container isn't always running, hence you need to start the container to run that task. Secondly, you'd like to pick up the app name dynamically. If both of those ring true, I think your solution needs to be re-architected to fit the scenario. Before I propose any ideas, am I interpreting your problem correctly? |
Beta Was this translation helpful? Give feedback.
-
Just double checking-- are you running Chadburn service elsewhere on the host, such as another compose, or using the binary? Because the Chadburn service doesn't appear in what you provided. (just asking, in case it somehow got overlooked) The Chadburn service should always be running, so a restart: "always" should be used. As far as I can tell, your docker-compose stack looks good so far, but only missing the Chadburn service, like so:
Just a couple of notes:
|
Beta Was this translation helpful? Give feedback.
-
I was thinking of a "hack" but I'm not familiar enough with go to implement it without some guidance. How could I implement a new label modifier like for instance for each service I wanted to backup, I would add the following labels
And while that service is running chadburn would |
Beta Was this translation helpful? Give feedback.
-
hey @maietta I've been able to patch the code to allow |
Beta Was this translation helpful? Give feedback.
-
Hey @maietta thanks for your work on this project! I may have an uncommon request - I use docker-compose and each of my stacks has a custom image that should be used to run backups (it has some tools installed that I don't want to include in the app containers for security reasons). I wasn't particularly happy with any existing backup solutions I found so far for several reasons. That custom container uses an image declared in a docker-compose.override.yml file file with labels and arguments to simplify deployments and keep things "clean" and dynamic. e.g
The backup container executes and should die after first execution and start again based on the schedule. Ideally it would be great if I could add those labels to the main app declared in "${APP_SVC_NAME}" environment variable. The labels would tell the scheduler that the "${APP_SVC_NAME}_backup" sidecar should be executed at the specified intervals.
However at the moment, this wont work because it would require
job-run
as opposed tojob-exec
and my "temporary" solution is to keep the backup container running and usejob-exec
on it. This is not ideal (resource consumption) and I would really like to keep away from a static config file that I'd have to update manually. I've tried to usejob-run
from the main app labels but it doesn't register.Is my idea possible? What would be the challenges?
Beta Was this translation helpful? Give feedback.
All reactions