Dockerfile for dcron (keywords: cron, crontab)
In scripts/
sub-directory are custom scripts called by crontab, e.g. arangodb-snapshot.sh
for backingup arango database daily:
#!/bin/bash
set -e
BASE_DUMP_DIR=/var/lib/arangodb3/backups
CUR_DUMP_DIR="mydb-dump-`date '+%Y%m%d%H%M%S'`"
TAR_BALL="${CUR_DUMP_DIR}.tgz"
mkdir -p "$BASE_DUMP_DIR"
cd "$BASE_DUMP_DIR"
docker exec my-arango arangodump \
--server.database=mydb \
--server.username='root' --server.password='' \
--output-directory="${BASE_DUMP_DIR}/${CUR_DUMP_DIR}"
tar -cvzf "$TAR_BALL" "$CUR_DUMP_DIR"
## Send to cloud-storage
## Notify success
Run:
docker run -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/amidala/arangodb3:/var/lib/arangodb3 cron
#!/bin/sh
set -e
# see: https://github.com/dubiousjim/dcron/issues/13
# ignore using `exec` for `dcron` to get another pid instead of `1`
# exec "$@"
"$@"
FROM docker
# Ref: https://github.com/xordiv/docker-alpine-cron
MAINTAINER wonderbeyond@gmail.com
RUN apk add --no-cache dcron bash tar
RUN mkdir -p /var/log/cron && touch /var/log/cron/cron.log
RUN rm -rf /etc/cron.d && mkdir -p /etc/cron.d
COPY ./docker-entry.sh /usr/local/bin
COPY ./scripts /usr/local/bin
RUN chmod +x /usr/local/bin/*
COPY ./crontabs/* /etc/cron.d
ENTRYPOINT ["docker-entry.sh"]
CMD ["crond", "-f", "-s", "/etc/cron.d", "-L", "/var/log/cron/cron.log"]