Delayed Restarts

See what we're up to: Runway is here! 🚀

Delayed restarts #

A delayed restart via Docker Swarm’s restart_policy provides a native way to implement periodic tasks.

Setup #

Add the following service to your stack:

10
11
12
13
14
15
16
17
18
...
  backup:
    image: minio/mc
    command: sh -c "mc cp -r /backup minio-alias/bucket"
    volumes:
      - backup:/backup:ro
    deploy:
      restart_policy:
        delay: 1800s

In this example, the service will start every 30 minutes and run the mc command to backup the files.

For brevity, we omit the configuration of the `mc` client, but see the [official documentation](https://docs.min.io/docs/minio-client-complete-guide) for help.

Tips #

When multiple jobs are deployed, execution (via the delay) may need to be spread out:

  • each job requires certain resources to start and run
  • executing many of jobs in parallel can impact other services