Create Docker image for a Java app in GIT

Hello,

I am new to Docker and I’m trying to create an image for a Java, where the code is hosted in GIT repo. So first checkout code from repo and then need to build with ant. This image will run on CentOS6.7 machine.
As I understood there are two ways to do this,

  1. Use Centos image as base and install java, git, ant and do the rest, but I couldn’t be able to find a good example on how to do this. If you know any please let me know :star:.
  2. Can I have java, ant, git installed in host machine and create java app docker image from scratch to just checkout repo and build? :star:

And once the image is ready, I need run the docker image, so once app hosted I need to schedule some cron jobs (which will run using above app jar). Please provide some docker image run command for such a requirement. :star:

Any help appreciated, thanks in advance.