-
Notifications
You must be signed in to change notification settings - Fork 183
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
Comments
if your target running container has a shell with 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
|
Ofelia currently doesn't support this, however functionality to send a signal to the container on schedule might be a good idea. Something like |
Thanks @jsnfwlr One enhancement to the essential last suggestion is using This is really useful when you wish to emulate the behavior of a remote Scheduled Job. The following docker-compose extract demonstrates the approach a bit further. The use case is rotating a key via a custom cli baked into a distroless image. The reason to continuously rotate a key locally is to ensure developers don't cache a key in a way that is incompatible with expected rotation in the remote environment. Agreed it would be handy if ofelia, which has an internal docker-client package, exposed some cli function to do this, but the following works just fine. # docker-compose.yml
# ...
# this container runs command and exits
# env vars, mounts etc omitted
example-key-rotation:
image: your-cli-image:local
command:
- key-rotation
container_name: example-key-rotation
# ofelia
example-key-rotation-scheduled:
image: mcuadros/ofelia:latest
depends_on:
example-key-rotation:
condition: service_completed_successfully
command: daemon --docker
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
labels:
ofelia.job-run.example-key-rotation.schedule: "@every 10m"
ofelia.job-run.example-key-rotation.command: "sh -c 'docker restart example-key-rotation'"
ofelia.job-run.example-key-rotation.image: "docker:cli"
ofelia.job-run.example-key-rotation.volume: "/var/run/docker.sock:/var/run/docker.sock"
# ... |
@expertonium thanks for improving on and completing the work around I suggested |
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!
The text was updated successfully, but these errors were encountered: