aptible / supercronic

Cron for containers
MIT License
1.84k stars 112 forks source link

Include detailed instructions in documentation #56

Closed edlington closed 4 years ago

edlington commented 4 years ago

From the documentation it's unclear to me how to get supercronic into a cron job in a Docker container. Say I specify a non-root system user in the Dockerfile before making the call to RUN usr/bin/crontab... how does supercronic fit into all of this?

zoispag commented 4 years ago

Supercronic is a replacement for unix cron. You use either one or the other.

Example Dockerfile

FROM debian

ENV SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.6/supercronic-linux-amd64 \
    SUPERCRONIC=supercronic-linux-amd64 \
    SUPERCRONIC_SHA1SUM=c3b78d342e5413ad39092fd3cfc083a85f5e2b75

RUN apt-get update && \
    apt-get install -y \
        bash \
        curl \
        vim && \
    apt-get -y autoremove

RUN curl -fsSLO "$SUPERCRONIC_URL" && \
    echo "${SUPERCRONIC_SHA1SUM}  ${SUPERCRONIC}" | sha1sum -c - && \
    chmod +x "$SUPERCRONIC" && \
    mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" && \
    ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic

and example docker-compose.yml

version: '3.5'
services:
  scheduler:
    build:
      context: .
      dockerfile: Dockerfile
    command: "supercronic /crontab"
    volumes:
      - ./crontab:/crontab:ro
krallin commented 4 years ago

What @zoispag says is correct — you just write your crontab to a file and point Supercronic to it. You don't run Supercronic through cron. I'm sorry this was unclear to you.