Skip to main content

Step by Step Setup Guide for Swarm Cronjobs

 GitHub-logo.png   logo (1).png   Swarm-Cronjob.png

 

 

 

 

Introduction

This wiki article will guide you through the setup of Docker Swarm Cronjobs. Follow the steps below to deploy and configure cron-like scheduled tasks in your Docker Swarm environment efficiently.

Setup Guide

Step 1: Create a Docker Compose YAML

Create a Docker Compose file with the latest image:

version: "3.2"

services:
  swarm-cronjob:
    image: crazymax/swarm-cronjob:latest
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
    environment:
      - "TZ=Europe/Paris"
      - "LOG_LEVEL=info"
      - "LOG_JSON=false"
    deploy:
      placement:
        constraints:
          - node.role == manager

Change the TZ environment variable to match your timezone.

 

Step 2: Deploy the Stack

Run the stack using one of the following methods:

  • Command Line: Use the command:
docker stack deploy -c docker-compose.yaml swarm-cronjob

If you are interested in configuring a System Prune job, check out the System Prune Configuration Guide.