When to pull from Docker repo and when from Git repo and then build?

Docker and Git are 2 completely different technologies. Git is a Source Control solution, while in docker you can run apps in docker containers. Think of it a sort of 'new' virtualisation technology. You can use both at the same time hower, no problem.

.... EDIT ...

Docker doesn't keep a copy of your source code. With docker you can build an image based on your source code and put that in a repository. From that image you can run an app in a docker container. So as for workflow basically, you just develop using git, and for deployment you use Docker...


Docker push command, pushes your images to the docker repository, images is not the source code, although may contain source code, and successive pushes for images can override each other and doesn't provide versioning. It is used for pulling images and running containers. Docker Repo further info

On the other hand git push, pushes your source code and other files to the the remote repository. Which is for version controlling. You can pull, fork or pull request to a remote git repository, and can build application from source code. Git Repo further info

They can be used together, and actually is being used together by many developers. They aim to solve different problems.


like the other answers say, git is for version control, e.g. for textfiles.

You build a docker container from a "dockerfile" (which is a textfile). This "dockerfile" is placed in a directory with many other files and folders.

So if you put this directory, where the dockerfile is located in, into a git repository, then everyone who has access to it, can build the same docker container, with the same configurations and everything.

is that what you mean?

So, the docker container is a "building" and the DOCKER-repository is a market where you can download already built buildings (images), from that you can run a virtualmachine/container.
And the files in the GIT-repository (this is like a big archive for e.g. documents) are the "construction plans". You "share" the different version of the "construction plans" via git, so everyone can build every version of the building.

Example Workflow:

In your development environment (your local computer):

  1. git pull - pull the "construction - instructions" from git repository (e.g. dockerfile)
  2. docker build - build the docker image from that dockerfile-instructions
  3. docker push myDockerRepo/myDockerImage:latest - push the newly built docker image into the DOCKER repository (NOT the git-repository)

In your production environment:

  1. docker pull myDockerRepo/myDockerImage:latest - pull the latest docker image from the DOCKER-repository
  2. docker run - run a new containerized instance (basically a VirtualMachine) FROM the docker image