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

Scheduled restarts #2064

Open
rcarmo opened this issue Dec 20, 2024 · 1 comment
Open

Scheduled restarts #2064

rcarmo opened this issue Dec 20, 2024 · 1 comment

Comments

@rcarmo
Copy link

rcarmo commented Dec 20, 2024

Is your feature request related to a problem? Please describe.

I would like to have an easy way to schedule restarts of specific containers - possibly using labels

Describe the solution you'd like

Something like this added to each service I would like to restart:

 labels:
      com.centurylinklabs.watchtower.daily_restart: "true"
      com.centurylinklabs.watchtower.restart_time: "05:00"

I don't see a need for anything as elaborate as a cron expression, but that might be another way

Describe alternatives you've considered

I've been using additional containers with an inline script to do it like so:

version: "3"
services:

  myservice:
    container_name: myservice

  restarter:
    image: docker:cli
    restart: unless-stopped
    volumes: ["/var/run/docker.sock:/var/run/docker.sock"]
    entrypoint: ["/bin/sh","-c"]
    command:
      - |
        while true; do
          current_epoch=$$(date +%s)
          target_epoch=$$(( $$(date -d "05:00" +%s) + 86400 ))
          sleep_seconds=$$(( target_epoch - current_epoch ))
          echo "$$(date) + $$sleep_seconds seconds"
          sleep $$sleep_seconds

          docker restart myservice
        done

Additional context

No response

Copy link

Hi there! 👋🏼 As you're new to this repo, we'd like to suggest that you read our code of conduct as well as our contribution guidelines. Thanks a bunch for opening your first issue! 🙏

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

1 participant