Can I keep multiple docker-compose.yml files in same directory? e.g.
i want docker-compose-1.yml with some services and docker-compose-2.yml with some other services. Is there any requirement to have specific file names and what is the command used to start it ?
docker-compose up --build -f docker-compose-1.yml ??
this results in
ERROR:
Can't find a suitable configuration file in this directory or any
parent. Are you in the right directory?
Supported filenames: docker-compose.yml, docker-compose.yaml
you can keep indeed multiple docker-compose
files with different names(they can be completely custom) in the same directory and start them all at the same time.
Try this:
docker-compose -f docker-compose1.yml -f docker-compose2.yml up --build
The -f
arguements should be before the up
and then --build
after.
Please note that in the case of many docker compose files these files are merged, check here for more info: https://docs.docker.com/compose/extends/#multiple-compose-files
You can run the services in multiple docker-compose files using parameter -p
-p, --project-name NAME
So, the following command should work:
docker-compose -f ./docker-compose-new.yml -p new_project_name up -d
See this parameter at docs.
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