A common design pattern is to clone and compile your project as you build your Docker image. In addition, you can configure your image as a Docker Automated Build , which is defined in the Docker documentation as:
Automated assemblies are a feature of the Docker Hub that allows you to use Docker Hub clusters to automatically create images from the specified Docker file and the GitHub or Bitbucket repository (or "context"). The system will clone your repository and build the image described by the Dockerfile, using the repository as context. The resulting auto image will be uploaded to the Docker Hub registry and marked as auto build.
Auto build starts anytime when you commit (and click) into the repo branches that you specify. If this fails too often, perhaps you should point to another branch.
In any case, if you decide to launch the git clone when starting a new container, you can configure your Docker file using CMD ["my-script"] , being CMD ["my-script"] script with any bash script with the code you want.
source share