Best practices for getting code into a container (git clone vs. copy vs. data container)

Hi @dineshbhat
the entrypoint method seems to be a very simple approach. May I know if you were able to get it working?
According to this [1], it should be possible

[1] https://docs.docker.com/engine/reference/builder/#understand-how-cmd-and-entrypoint-interact
Best

Hi

I need basic thing how can i clone public git repo into docker container, but still not found any helpful information. Seriously very poor documentation from docker.

This is not remotely what docker themselves should handle, non the less, install git and do git clone either inside the container, or, as more prefered you run git clone outside the container, and use the copy method provided with docker to copy the project inside the container.

Creates a new subdirectory named .git that contains all of your necessary repository files — a Git repository skeleton. Nothing in your project is tracked yet. (See Git Internals) for more information about exactly what files are contained in the .git directory you just created.)

If you want to start version-controlling existing files (as opposed to an empty directory), you should probably begin tracking those files and do an initial commit.

Cloning an Existing Repository

Clone a repository with git clone <url> . Example, if you want to clone the Git linkable library called libgit2 , Hope it helps. Go2top FIFA 18.

The focus should be to use container as one thing only and not complicate stuff. Containers are best left performing microservices operations. The ideal way would be to employ a continuous deployment pipeline through jenkins or any CI/CD. The CI/CD system creates a new image every time a code is pushed and deploys the container to your dev environment. I understand that setting up such pipeline can be time consuming, so I guess the best way is to mount the project directory to container where tomcat can see it.

I am surprised that nobody seems to mention here the important issues of git clone in the building of an image:

  • security issues (storing sensitive information like git credentials into an image sent on the web);
  • breaking of Docker’s caching logic.

These are explained in this Stackoverflow thread where BMitch’s answer seems to provide the best alternatives.