Closed mladedav closed 1 day ago
Add --override-file which would merge a file into the compose file if it exists and not produce an error if it doesn't.
I'm worried such a flag would be confusing with the merge ability offered by --file
, then people will complain compose silently ignores missing file as they do a typo.
it would be convenient if docker compose just found
.override.yml automatically.
Indeed, still such a change would have major impact for users who already have such an override but don't expect it to be selected. We can't adopt such an approach.
The alternative you describe is a common pattern used by many compose users, relying on --project-directory
flag. I recommend this approach
Another option is to declare compose files to be loaded inside your .env
file using COMPOSE_FILES=...
The .env
approach would have the same issue as --file
, would it not? If the file doesn't exist, compose would fail.
Do I understand it correctly that you're worried users would accidentally type --optional-file
instead of --file
and then be surprised the file was not required?
Do I understand it correctly that you're worried users would accidentally type --optional-file instead of --file and then be surprised the file was not required?
yes, won't be obvious how those two flags differ and I can guess some won't understand they can just repeat --file
to provide overrides - nobody reads the docs you know. Flag should at least make it obvious target file is optional, and then I'd prefer we get some custom syntax to mark a file as optional (maybe elvis operator style --file=?:foo.override.yaml
)
anyway, for your use-case the existing and common practice you already identified is to use per-environment folder with relevant files
Ok, thanks for your time. If you believe it would cause problems it's probably not worth it.
I'll probably rename and nest the files then.
Description
Issues
Currently, when a file is not specified,
docker compose
picks upcompose.yml
and optionallycompose.override.yml
if it exists.I have a project with multiple compose files so each has specific name and I'd like to have an option to have override files for these but having
first-compose.yml
andfirst-compose.override.yml
, the second is not automatically used. If I pass both with the-f
option, the second must exist.Proposal
Add
--override-file
which would merge a file into the compose file if it exists and not produce an error if it doesn't. It would have to be specified after--file
has been specified and it would be merged along with other--file
options in the order it has been specified on the command line.Alternatively, I belive the
.override.yaml
files used to be picked up and it would be convenient ifdocker compose
just found<docker-compose-name>.override.yml
automatically.Alternatives
Use
first/compose.yml
andfirst/compose.override.yml
instead.