Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerfile example alpine with cron enabled #26

Open
FloCola opened this issue Aug 7, 2022 · 2 comments
Open

Dockerfile example alpine with cron enabled #26

FloCola opened this issue Aug 7, 2022 · 2 comments

Comments

@FloCola
Copy link

FloCola commented Aug 7, 2022

quite handy, have it running on a Synology NAS. Should be running almost anywhere.

Preconfig:

  • Download script, save it accessible for the container.
  • Script: Change first line to '#!/bin/ash'
  • Script: Preconfigure Script-Parameters, or add script parameters to cronjob.
  • Dockerfile: Change echo for cronjobs to your needs. See example.
  • Mount Container Folder with scripts to '/srv'
# Dockerfile to create image with cron services
FROM alpine:latest

#Configure
RUN apk add --no-cache curl
RUN apk add --no-cache bind-tools
RUN apk add --no-cache jq

#Cronjobs
RUN echo '*/5     *       *       *       *       /bin/ash /srv/hetzner-dyndns_alpine.sh >> /srv/hetzner-dyndns.log' >> /root/crontab.conf


# Add the cron job
RUN crontab /root/crontab.conf

# Run the command on container startup
CMD [ "/usr/sbin/crond", "-f", "-d8" ]
@kladderadeng
Copy link

Awesome @FloCola! That helped me a lot :-)

@thcrt
Copy link
Contributor

thcrt commented Dec 16, 2023

It's worth noting that installing bind-tools should no longer be necessary, as #35 uses an HTTP API to get the host's IP instead of using dig or nslookup.

It could be a good idea to automate Docker builds to GHCR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants