I'm looking for best practices to share the Docker compose files created by developers with the people that do the deployment.

We use 2 docker compose files: docker-compose.yml and docker-compose.prod.yml.

These files are included in version control (git in our case).

We have 2 options:

  1. Include the compose files in the master branch, and checkout the entire master branch when the application needs to be deployed. Pro here is that it is easy to keep everything in sync, con that the entire projects needs to be cloned on the server when the application is deployed.
  2. Include the compose files in a orphaned branch that can be checked out when the application needs to be deployed. The pro here is that only the compose files will be checked out, con that we have 2 branches that needs to be maintained.

Since we are fairly new to this, I'm wondering how other organizations approach this, and why one method should be preferred over the other?

  • I know the tension you are feeling ... we went with keeping the devops scripts and tooling in same github repo as the main app so things stay in sync better ... we have just one prod domain however 18 dev domains each on their own VPS server across various branches so keeping devops code in bed with the main code base does work and seems the simpler approach Commented Jun 5, 2018 at 15:44

1 Answer 1


Some thoughts:

  1. You do not have to clone the entire project. https://stackoverflow.com/questions/2466735/how-to-checkout-only-one-file-from-git-repository-sparse-checkout?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa discusses how to checkout a single file. I have also had good results using curl to get single files off github.
  2. You can containerize it. Like this
FROM docker/compose:1.21.2
RUN mkdir /src
COPY docker-compose.yml /src/docker-compose.yml
ENTRYPOINT ["docker-compose"]
CMD []

You can containerize docker-compose just like any other application.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.