Deprecated! Please use blacklabelops/jobber:cloud!
5.7K
Supports:
In short, you can define periodic tasks your cloud environments.
Example:
$ docker run -d --name cloudtask \
-e "TUTUM_USER=YOUR_USER" \
-e "TUTUM_PASS=YOUR_PASSWORD" \
-e "JOB_NAME1=TestEcho" \
-e "JOB_COMMAND1=tutum service ps" \
-e "JOB_TIME1=1" \
-e "JOB_ON_ERROR1=Backoff" \
blacklabelops/cron-cloud
Will list your tutum services each minute.
This container is using blacklabelops/jobber for defining jobs. See this link for a comprehensive documentation: (blacklabelops/jobber)[https://github.com/blacklabelops/jobber-cron]
The image also overs environment variables for authenticating yourself against your favourite cloud environment.
Required Environment Variables:
Optional Environment Variables:
Example:
$ docker run -d --name cloudtask \
-e "TUTUM_USER=YOUR_USER" \
-e "TUTUM_PASS=YOUR_PASSWORD" \
-e "JOB_NAME1=TestEcho" \
-e "JOB_COMMAND1=tutum service ps" \
-e "JOB_TIME1=1" \
-e "JOB_ON_ERROR1=Backoff" \
blacklabelops/cron-cloud
Will list your tutum services each minute.
Required Environment Variables:
Optional Environment Variables:
Simply put your credentials inside the environment variables and call:
$ docker run -d --name cloudtask \
-e "AWS_ACCESS_KEY_ID=YOUR_ACCESS_KEY" \
-e "AWS_SECRET_ACCESS_KEY=YOUR_SECRET_KEY" \
-e "AWS_DEFAULT_REGION=YOUR_REGION" \
-e "JOB_NAME1=TestListingBuckets" \
-e "JOB_COMMAND1=aws s3 ls" \
-e "JOB_TIME1=1" \
-e "JOB_ON_ERROR1=Backoff" \
blacklabelops/cron-cloud
Will list your buckets each minute.
You can run commands against existing cloud projects!
Documentation can be found here: Creating & Deleting Projects
Also you will have to activate APIs manually before you can use them!
Documentation can be found here: Activating & Deactivating APIs
There are two ways to authenticate the gcloud tools and execute gcloud commands. Both ways need a Google Cloud OAuth Service Account file. This is documented here: Service Account Authentication.
You can now mount the file into your container and execute commands like this:
$ docker run -it --rm \
-v $(pwd)/auth.json:/auth.json \
-e "GCLOUD_ACCOUNT_FILE=/auth.json" \
-e "[email protected]" \
blacklabelops/cron-cloud \
bash
$ gcloud compute instances list
Opens the bash console inside the container, the second command is executed inside the authenticated container. This works both with json and P12 key files.
You can also Base64 encode the authentication file and stuff it inside an environment variable. This works perfect for long-running stand-alone containers.
$ docker run -it --rm \
-e "GCLOUD_ACCOUNT=$(base64 auth.json)" \
-e "[email protected]" \
blacklabelops/cron-cloud \
bash
$ gcloud compute instances list
Opens the bash console inside the container, the second command is executed inside the authenticated container. This works both with json and P12 key files.
Set your default Google Project by defining the CLOUDSDK_CORE_PROJECT environment variable.
$ docker run -it --rm \
-e "GCLOUD_ACCOUNT=$(base64 auth.json)" \
-e "[email protected]" \
-e "CLOUDSDK_CORE_PROJECT=example-project" \
blacklabelops/cron-cloud \
bash
$ gcloud compute instances list
Runs all commands against the project
example-project.
Set your default Google Project Zone and Region with the environment variables CLOUDSDK_COMPUTE_ZONE and CLOUDSDK_COMPUTE_REGION.
The documentation can be found here : Regions & Zones
Example:
$ docker run -it --rm \
-e "GCLOUD_ACCOUNT=$(base64 auth.json)" \
-e "[email protected]" \
-e "CLOUDSDK_CORE_PROJECT=example-project" \
-e "CLOUDSDK_COMPUTE_ZONE=europe-west1-b" \
-e "CLOUDSDK_COMPUTE_REGION=europe-west1" \
blacklabelops/cron-cloud \
bash
$ gcloud compute zones list
$ gcloud compute regions describe ${CLOUDSDK_COMPUTE_REGION}
Set your region and zone to belgium. More details appear with the
describecommand.
When it comes to the cron string then Jobber is a little bit different. If you do not define any time then the resulting cron table will be
* * * * * *
and the job will be executed every second.
You can also define just one number "1". This will be interpreted as
1 * * * * *
so you can see that you have to specify the time string from the back and the rest will be filled up by Jobber.
As a reminder, cron timetable is like follows:
You will need a docker demon in order to enable docker cli or docker-compose. Simply mount your local docker demon or start one inside a linked container!
Example mounting local docker demon:
$ docker run -d \
-v /var/run/docker.sock:/var/run/docker.sock \
-e "DOCKER_HOST=" \
-e "JOB_NAME1=TestEcho" \
-e "JOB_COMMAND1=docker images" \
-e "JOB_TIME1=1" \
-e "JOB_ON_ERROR1=Backoff" \
blacklabelops/cron-cloud
Will list local image list every minute.
Example using separate docker demon container:
Start a Docker demon container!
$ docker run -d --privileged --name docker_demon docker:1.9.1-dind
The swarm-slave does not run a docker demon itself! We use the official Docker image to create one for all slaves.
Now start the cron-cloud container!
$ docker run -d \
--link docker_demon:docker \
-e "JOB_NAME1=TestEcho" \
-e "JOB_COMMAND1=docker version" \
-e "JOB_TIME1=1" \
-e "JOB_ON_ERROR1=Backoff" \
blacklabelops/cron-cloud
Will print the docker version every minute.
The container can be started and login in a remote repository. The default is the dockerhub registry.
With the environment variables:
Example:
$ docker run -d \
--link docker_demon:docker \
-e "DOCKER_REGISTRY_USER=**Your_Account_Username**" \
-e "DOCKER_REGISTRY_EMAIL=**Your_Account_Email**" \
-e "DOCKER_REGISTRY_PASSWORD=**Your_Account_Password**" \
-e "JOB_NAME1=TestEcho" \
-e "JOB_COMMAND1=docker push blacklabelops/centos" \
-e "JOB_TIME1=1" \
-e "JOB_ON_ERROR1=Backoff" \
blacklabelops/cron-cloud
Will push the container to dockerhub every minute.
The default for this container is dockerhub.io. If you want to use another remote repository, e.g. quay.io then Your_Account_Email can specify the repository with the environment variable DOCKER_REGISTRY.
Example:
$ docker run -d \
--link docker_demon:docker \
-e "DOCKER_REGISTRY=quay.io"
-e "DOCKER_REGISTRY_USER=**Your_Account_Username**" \
-e "DOCKER_REGISTRY_EMAIL=**Your_Account_Email**" \
-e "DOCKER_REGISTRY_PASSWORD=**Your_Account_Password**" \
-e "JOB_NAME1=TestEcho" \
-e "JOB_COMMAND1=docker push blacklabelops/centos" \
-e "JOB_TIME1=1" \
-e "JOB_ON_ERROR1=Backoff" \
blacklabelops/cron-cloud
Will push the container to quay.io every minute.
Content type
Image
Digest
Size
223.3 MB
Last updated
almost 8 years ago
docker pull blacklabelops/cron-cloud