Scheduling a Docker Container or Installing Scheduler in Container I have an interesting question related to scheduling my Docker Container. 

I have a virtual machine with a docker image inside of it. I can spin up a container from the image that has an entrypoint (jar). 

I am in a dilemna on how I should schedule the jobs to run against the jar. 

Here are my 2 options:  

1) If I run a cron on the VM then I can call the docker run commands to produce a container and run different jobs against the jar. The issue here is that once a single job is run, the container automatically terminates and the second job has no previous histroy of the previously run jobs. I believe theres a way to keep a container running forever with an entry point but I haven't explored/tested this yet. 

2) I can install a cron inside of the container and through the Dockerfile provide the cron for updating - however, the issue here is how would I launch the container and keep it running for the cron jobs to run? 

If you need any further details please do let me know. 

Thanks!
You don't need cron. Most server OS-es (CoreOS, RedHat, CentOS, Ubuntu, etc.) these days run systemd, and systemd unit files can run your container to execute the job, for example:

Two unit files. One is mytimedstuff.service and mytimedstuff.timer. The .timer defines when the service should be executed.

In mytimedstuff.service

[Unit]
Description=Executes mystuff
After=default.target docker_network_apps.service
Requires=default.target docker_network_apps.service

[Service]
Type=oneshot
User=root
ExecStartPre=/usr/bin/docker pull mystuff:stable
ExecStartPre=-/bin/bash -c "/usr/bin/docker rm -f mystuffcontainer 2&gt;/dev/null"
ExecStart=/bin/bash -c "/usr/bin/docker run --name mystuffcontainer mystuff:stable mystuff"


In mytimedstuff.timer:

[Unit]
Description=My stuff runs at 00:10 sharp.

[Timer]
OnCalendar=00:10:00

[Install]
WantedBy=multi-user.target