Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to name docker-compose files

How do you name your docker-compose.yml files? Is there a convention to follow?

With Dockerfiles <purpose>.Dockerfile seems to work the best being instantly recognized by VSCode and PyCharm.

I like the idea of structuring docker/compose files into folders so that default names could be used, but as far as I know docker can't see files up the tree creating different problems.

like image 394
rrebase Avatar asked Jan 25 '23 02:01

rrebase


1 Answers

According to the -f documentation:

If you don’t provide this flag on the command line, Compose [...] looks for a docker-compose.yml and a docker-compose.override.yml file.

If you don't want to use the -f flag you can use the default name docker-compose.yml and override it with docker-compose.override.yml.


However, if you use -f, since you'll provide the filename, you can use whatever you want.

I think a good way to name them depending on the environment could be docker-compose.{env}.yml and place them at the top level directory:

  • docker-compose.prod.yml
  • docker-compose.dev.yml
  • docker-compose.test.yml
  • docker-compose.staging.yml

And you can use the default docker-compose.yml to define the base configuration that is common to all environments.

like image 104
Mickael B. Avatar answered Jan 29 '23 16:01

Mickael B.