Reputation: 4804
I start to work with a new project using Docker and I can see there is no docker-compose.yml
file there, but a few files like docker-compose.myname1.yml
, docker-compose.myname2.yml
instead. Trying to run docker-compose up
I get an error:
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
So I wonder if that's possible for a Docker project to work without the docker-compose.yml
file and if it is, what conditions should be met. Maybe that's the matter of some specific version or environment?
Upvotes: 6
Views: 3927
Reputation: 308
https://docs.docker.com/compose/reference/
"Options: -f, --file FILE Specify an alternate compose file (default: docker-compose.yml)"
so in your case that would be:
docker-compose -f dockcer-compose.myname1.yml up
docker-compose -f dockcer-compose.myname2.yml up
Upvotes: 9
Reputation: 14846
There are two different issues presented in your question:
docker-compose up
, you must be in a directory that contains docker-compose.yml
(or '.yaml
), as indicated by the error you are receiving.COMPOSE_FILE
is set to something else.In order to use an alternative file, you can take one of these approaches:
docker-compose
with the --file
argument:$ docker-compose --help
-f, --file FILE Specify an alternate compose file
(default: docker-compose.yml)
COMPOSE_FILE
environment variable prior to running any docker-compose
command.Upvotes: 0