Sign inSign up

itsziget/docron

By itsziget

•Updated over 8 years ago

Crontab in Alpine-based Docker container

Image
0

1.4K

itsziget/docron repository overview

⁠Docker Cron

You can run scheduled tasks in a Docker container using this image. In addition, this is based on library/docker⁠ so docker is available as a command as you would use it from the host. You just need to bind mount the docker socket file from your host.

⁠Example

docker run -d \
   -v /var/run/docker.sock:/var/run/docker.sock \
   -v $(pwd)/crontab:/etc/crontabs/root \
   --name cron \
   itsziget/docron

If you want to run commands working with dates and times without docker, you may want to set a timezone. You can do this by setting variable TIMEZONE. Alternatively, you can set TZ which is compatible with debian images.


docker run -d \
   -e TZ=Europe/Budapest \
   -v /var/run/docker.sock:/var/run/docker.sock \
   -v $(pwd)/crontab:/etc/crontabs/root \
   --name cron \
   itsziget/docron

Generally it is recommended to use the same version inside the container as you have on the host, but the image on Docker Hub contains only the latest stable version. If you have different version installed on your machine, download the source from GitHub and build any version you need.

git clone https://github.com/itsziget/docron.git docron
cd docron
docker build --build-arg DOCKER_VERSION="<version>" -t docron-custom .  

You can use the build script to build exactly the same version as you have on the host:

chmod +x build.sh
./build.sh my-custom-docron

Tip: You can automatically generate crontab file by itsziget/docron-gen⁠

Tag summary

Content type

Image

Digest

Size

40 MB

Last updated

over 8 years ago

docker pull itsziget/docron