Custom made image to run cron inside container along with PHP7.1 CLI support.
215
This tailor-made alpine based image will let you run cron inside a Docker container.
Below is a command to run a Docker container using this image.
docker run --rm -e "TZ=America/Phoenix" --name="alpine-cron-sample" -d \
-v /ABS_PATH/crontabs:/var/spool/cron/crontabs \
-v /ABS_PATH/logs:/var/log/cron \
intekhabrizvi/php-cli-7.1-cron
| Name | Explanation |
|---|---|
| "TZ=America/Phoenix" | By default container start with UTC as timezone but you can use this param to change containers timezone. Acceptable values can be found at [http://www.timezoneconverter.com/cgi-bin/zoneinfo] |
| /ABS_PATH/crontabs | An absolute path to the local folder where you will store your crontab file. Inside this folder you should have a single file named root and that file will have all your commands just like crontab file. Read Example crontab file |
| /ABS_PATH/logs | An absolute path to the local folder where you want cron logs files to be created. |
Below is an example content of your starting crontab file.
*/1 * * * * echo "This is a test" >> /var/log/cron/cron.log 2>&1
*/1 * * * * php -m >> /var/log/cron/cron.log 2>&1
Below is the content of Dockerfile I used to build the latest version of this image.
FROM php:7.1-cli-alpine
RUN apk add tzdata libxml2-dev freetype libpng libjpeg-turbo freetype-dev libpng-dev libjpeg-turbo-dev
RUN apk add --no-cache $PHPIZE_DEPS
RUN docker-php-ext-install xml pdo_mysql mysqli bcmath soap gd zip
RUN pecl install mongodb && docker-php-ext-enable mongodb
RUN apk del --no-cache $PHPIZE_DEPS
RUN mkdir -p /var/log/cron && mkdir -m 0644 -p /var/spool/cron/crontabs && touch /var/log/cron/cron.log && mkdir -m 0644 -p /etc/cron.d
CMD ["crond", "-f", "-l", "8"]
MIT Provide as-is basis, I am not responsible for anything
Content type
Image
Digest
Size
-
Last updated
over 6 years ago
docker pull intekhabrizvi/php-cli-7.1-cron