Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restart containers on a schedule with ofelia? #280

Open
steilerDev opened this issue Jun 7, 2024 · 2 comments
Open

Restart containers on a schedule with ofelia? #280

steilerDev opened this issue Jun 7, 2024 · 2 comments

Comments

@steilerDev
Copy link

Hello Everyone :)

Is it possible to use ofelia to restart a running container on a schedule? Alternatively I need to find a way to kill it through job-exec.

Any pointer would be appreciated!

Thanks!

@jsnfwlr
Copy link

jsnfwlr commented Jun 26, 2024

if your target running container has a shell with pkill (or ps and kill) installed, and you know the name of the core process that is used to determine when the container will restart if restart: unless-stopped is set in the compose yaml, you could schedule a command to run to kill the process gracefully which would trigger the container to restart.

If your target container is using the s6 overlay, it will be harder to restart the container itself, but you could restart the service within the container.

Finally, if you know how to set container names (or have enough shell mastery to get container ids from docker ps), and if you are okay with running docker-in-docker you could implement a job-run config like:

[job-run "restart-other-container"]
schedule = @daily
image = docker:latest
command = sh -c 'docker restart <container-name>'
volume = /var/run/docker.sock:/var/run/docker.sock

@taraspos
Copy link
Collaborator

Ofelia currently doesn't support this, however functionality to send a signal to the container on schedule might be a good idea. Something like job-signal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants