I have docker where cron is ran using
CMD ["cron","-f"]
command. This writes the output to the cron log file.
Is there any way to redirect these logs to the console.
My Base Image looks like
FROM ubuntu:latest
RUN ls
RUN apt-get update
RUN apt install -y software-properties-common
RUN add-apt-repository -y ppa:openjdk-r/ppa
RUN apt-get update
RUN apt-get install -y openjdk-12-jre
RUN apt-get -y install cron wget unzip
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \
&& apt-get update -qqy \
&& apt-get -qqy install google-chrome-stable \
&& rm /etc/apt/sources.list.d/google-chrome.list \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/* \
&& sed -i 's/"$HERE\/chrome"/"$HERE\/chrome" --no-sandbox/g' /opt/google/chrome/google-chrome
ARG CHROME_DRIVER_VERSION=76.0.3809.68
RUN wget --no-verbose -O /tmp/chromedriver_linux64.zip https://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip \
&& rm -rf /opt/chromedriver \
&& unzip /tmp/chromedriver_linux64.zip -d /opt \
&& rm /tmp/chromedriver_linux64.zip \
&& mv /opt/chromedriver /opt/chromedriver-$CHROME_DRIVER_VERSION \
&& chmod 755 /opt/chromedriver-$CHROME_DRIVER_VERSION \
&& ln -fs /opt/chromedriver-$CHROME_DRIVER_VERSION /usr/bin/chromedriver
COPY tests-cron /etc/cron.d/tests-cron
RUN chmod 0644 /etc/cron.d/tests-cron
WORKDIR /etc/cron.d
RUN ls
RUN crontab /etc/cron.d/tests-cron
RUN touch /var/log/cron.log
WORKDIR /app
RUN mkdir pricetest
COPY --from=maven-container /app/ pricetest/
RUN cp /usr/bin/chromedriver ./pricetest
WORKDIR /app/pricetest
ENV SHELL=/bin/bash
CMD ["cron", "-f"]
PS: I am still work in progress on this project. So I havent optimized the docker build.
And the cronfile ( tests-cron
) I am contains
* * * * * root echo "Hello world"
Base image used: ubuntu:latest