问题
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
?
回答1:
default name:
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.
Docker reference:
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]
回答2:
You can specify an alternate filename on the command line.
-f, --file FILE Specify an alternate compose file (default: docker-compose.yml)
Ref: https://docs.docker.com/compose/reference/overview/
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.
来源:https://stackoverflow.com/questions/49718431/docker-compose-yml-file-naming-convention