Host a Docker container in Azure and have it active during a specific period of the day? Host a Docker container in Azure and have it active during a specific period of the day? kubernetes kubernetes

Host a Docker container in Azure and have it active during a specific period of the day?


Yes it is possible. Cronjobs is designed to run a job periodically on a given schedule, written in Cron format. A Job creates one or more Pods and will continue to retry execution of the Pods until a specified number of them successfully terminate.

To run your automation tests

  • You should create a Cronjob definition
  • Set the cron timer
  • Call your CMD

Here is a sample Hello Wordl example:

apiVersion: batch/v1kind: CronJobmetadata:  name: hellospec:  schedule: "*/1 * * * *"  jobTemplate:    spec:      template:        spec:          containers:          - name: hello            image: busybox            imagePullPolicy: IfNotPresent            command:            - /bin/sh            - -c            - date; echo Hello from the Kubernetes cluster          restartPolicy: OnFailure


You haven't given much information beside running and stopping a container. One of the simplest way is to use the Docker CLI to run an instance of your container in Azure Container Instances. You create and use a context for Azure and then, using docker run will create an ACI and run your container in Azure.

docker login azuredocker context create aci myacicontextdocker context use myacicontextdocker run -p 80:80 [yourImage]docker rm [instanceName]

Ref: https://www.docker.com/blog/running-a-container-in-aci-with-docker-desktop-edge/ https://docs.microsoft.com/en-us/azure/container-instances/quickstart-docker-cli