Reputation: 35434
Reading the help by docker-compose -h
, or this official manual, will give us the option --project-directory PATH
docker-compose [-f ...] [options] [COMMAND] [ARGS...]
--project-directory PATH Specify an alternate working directory (default: the path of the compose file)
But I tried to call the below command and failed - I have ensured the file at ./mySubFolder/docker-compose.yml
has already been created.
docker-compose --project-directory ./mySubFolder up
The error
Can't find a suitable configuration file in this directory or anyparent.
Are you in the right directory?
Supported filenames: docker-compose.yml, docker-compose.yaml
What I did wrong? How to pass the parameter properly?
Upvotes: 63
Views: 80350
Reputation: 443
I have been using both -f
and --project-directory
as a continuous practice and it's clear for myself.
-f
helps find the target file if it is not in your current directory or you have multiple versions in a directory;
--project-directory
as reference for any path-relative variables defined inside the docker-compose.yaml
file
such as
docker-compose --project-directory ./ -f [path/to/any/docker-compose.yaml] up -d
Upvotes: 12
Reputation: 35434
Use the -f
param instead --project-directory
view details
You can use -f flag to specify a path to Compose file that is not located in the current directory
docker-compose -f /path/to/docker-compose.yml
Upvotes: 87