I'm trying to run an Node 12.13.0 Alpine Docker container that runs a script every 15 minutes. According to Alpine's wiki cron section, I should be able to just add a RUN task in the Dockerfile to run crond as a service via:
rc-service crond start && rc-update add crond
This however returns an error:
rc-service: service `crond' does not exist
Running a separate Docker container just to run the cron task against this Docker container is NOT an option. This container is already extremely lightweight, and doesn't do much.
Here is my Dockerfile:
FROM node:12.13.0-alpine
RUN apk add --no-cache tini openrc
WORKDIR /opt/app
COPY script.sh /etc/periodic/15min/
RUN chmod a+x /etc/periodic/15min/script.sh
RUN rc-service crond start && rc-update add crond
COPY . .
RUN chmod a+x startup.sh
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["./startup.sh"]
Any help here would be appreciated.
tini
in your example is a lightweight init that handles signals and reaps zombies but otherwise just runs a single child process.) "A separate container" or "the host cron" are the standard answers here. – Leralerch