where should I put docker-compose.yml

Amzero picture Amzero · Jun 27, 2017 · Viewed 9.3k times · Source

When I pull the images from docker hub. Sometimes, I would like to run the images in a multi-container way. So I choose to use docker-compose. For example, I would run the zookeeper in replicated mode. I will new a file named docker-compose.yml, and run docker-compose up and wait for it to initialize completely.

My question is what is proper directory I should put docker-compose.yml file into?

Answer

rrhrg picture rrhrg · Jan 3, 2018

I'm asking myself the same question: Where to put my docker-compose.yml file?

I've decided to do it the following way:

  • One Repo for the docker-compose.yml along with deployment scripts (Jenkins pipeline in my case).
  • One Repo per micro service along with a Dockerfile and its build logic (built image is pushed to private docker registry).

Why?

  • The docker-compose.yml describes a system (the composition of micro services) and how it is deployed.
  • A micro services should be independent from the system infrastructure.
  • There could be more than one system (different composition of the micro services) with a second docker-compose.yml (and Repo).

However, of course there are reasonable exceptions. Assume you're deploying a customized Database along with a management tool (e.g. customized mariadb and adminer), then most things may live in one repository.