Cronjobs

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

Running periodic tasks #

Sometimes an application require tasks to run on a certain schedule. To achieve this on Docker Swarm, the following options are available:

  1. Using Delayed restarts
  2. Using swarm-cronjob
  3. Using a containerized crond

General setup #

All examples build upon the following application/stack. The application writes files to a path called /backup which is backed up a backup Docker volume. For complete disaster recovery, the objective is to mirror the contents of the backup volume to a minio service.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
version: "3.8"

volumes:
  backup:

services:
  app:
    image: project/image:1.0
    volumes:
      - backup:/backups

Each example will use minio’s mc client to backup files from the local Docker volume to a remote minio.