Difference between revisions of "Create a Kali image running cron"
From MyWiki
| (7 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
| + | Sample 1 | ||
<source lang=yaml> | <source lang=yaml> | ||
FROM kalilinux/kali-rolling:latest | FROM kalilinux/kali-rolling:latest | ||
| Line 14: | Line 15: | ||
ENTRYPOINT [ "/entrypoint.sh" ] | ENTRYPOINT [ "/entrypoint.sh" ] | ||
| + | |||
| + | </source> | ||
| + | Sample 2 - running a cron job | ||
| + | |||
| + | <source lang=yaml> | ||
| + | FROM ubuntu:latest | ||
| + | |||
| + | # Install necessary software | ||
| + | RUN apt-get update && \ | ||
| + | apt-get -y install cron | ||
| + | |||
| + | # Add crontab file | ||
| + | COPY crontab /etc/cron.d/crontab | ||
| + | |||
| + | # Give execution rights on the cron job | ||
| + | RUN chmod 0644 /etc/cron.d/crontab | ||
| + | |||
| + | # Create the log file to be able to run tail | ||
| + | RUN touch /var/log/cron.log | ||
| + | |||
| + | # Start the cron service | ||
| + | CMD cron && tail -f /var/log/cron.log | ||
| + | |||
| + | </source> | ||
| + | Putting both of the above together | ||
| + | <source lang=yaml> | ||
| + | FROM kalilinux/kali-rolling:latest | ||
| + | |||
| + | ARG KALI_METAPACKAGE=core | ||
| + | ENV DEBIAN_FRONTEND noninteractive | ||
| + | RUN apt-get update | ||
| + | RUN apt-get -y upgrade | ||
| + | RUN apt-get -y install kali-linux-${KALI_METAPACKAGE} | ||
| + | RUN apt-get clean | ||
| + | |||
| + | |||
| + | RUN apt-get update && \ | ||
| + | apt-get -y install cron | ||
| + | |||
| + | # Add crontab file | ||
| + | #COPY crontab /etc/cron.d/crontab | ||
| + | |||
| + | # Give execution rights on the cron job | ||
| + | #RUN chmod 0644 /etc/cron.d/crontab | ||
| + | |||
| + | # Create the log file to be able to run tail | ||
| + | RUN touch /var/log/cron.log | ||
| + | |||
| + | # Start the cron service | ||
| + | CMD cron && tail -f /var/log/cron.log | ||
</source> | </source> | ||
Latest revision as of 13:06, 10 July 2024
Sample 1
FROM kalilinux/kali-rolling:latest ARG KALI_METAPACKAGE=core ENV DEBIAN_FRONTEND noninteractive RUN apt-get update RUN apt-get -y upgrade RUN apt-get -y install kali-linux-${KALI_METAPACKAGE} RUN apt-get clean COPY entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh ENTRYPOINT [ "/entrypoint.sh" ]
Sample 2 - running a cron job
FROM ubuntu:latest # Install necessary software RUN apt-get update && \ apt-get -y install cron # Add crontab file COPY crontab /etc/cron.d/crontab # Give execution rights on the cron job RUN chmod 0644 /etc/cron.d/crontab # Create the log file to be able to run tail RUN touch /var/log/cron.log # Start the cron service CMD cron && tail -f /var/log/cron.log
Putting both of the above together
FROM kalilinux/kali-rolling:latest ARG KALI_METAPACKAGE=core ENV DEBIAN_FRONTEND noninteractive RUN apt-get update RUN apt-get -y upgrade RUN apt-get -y install kali-linux-${KALI_METAPACKAGE} RUN apt-get clean RUN apt-get update && \ apt-get -y install cron # Add crontab file #COPY crontab /etc/cron.d/crontab # Give execution rights on the cron job #RUN chmod 0644 /etc/cron.d/crontab # Create the log file to be able to run tail RUN touch /var/log/cron.log # Start the cron service CMD cron && tail -f /var/log/cron.log