What is the naming convention for the docker-compose.yml
file? Should it always be named like this or am I free to rename it to, for instance, docker-compose-jenkins.yml
?
The default filename is docker-compose. yml . You can name the manifest name as you like, but you have to pass the filename in the docker-compose command.
Given that the tool supports using any file name you'd like, you're free to name the file whatever you'd like. In fact, you can even specify multiple files at once.
The Compose file is a YAML file defining services, networks and volumes. The default path for a Compose file is ./docker-compose.yml . Tip: You can use either a .yml or .yaml extension for this file. They both work.
Validating your file now is as simple as docker-compose -f docker-compose. yml config . As always, you can omit the -f docker-compose. yml part when running this in the same folder as the file itself or having the COMPOSE_FILE environment variable pointing to your file.
Note that docker-compose.yml
is the default name so if you want to use docker-compose up
without specifying a filename, you will need to use that format. As mentioned, you can use multiple files as overrides (see docs), by specifying one file per -f
argument.
The -f flag is optional. If you don’t provide this flag on the command line, Compose traverses the working directory and its parent directories looking for a docker-compose.yml and a docker-compose.override.yml file. You must supply at least the docker-compose.yml file. If both files are present on the same directory level, Compose combines the two files into a single configuration.
The configuration in the docker-compose.override.yml file is applied over and in addition to the values in the docker-compose.yml file.
[docs link]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With