简体   繁体   中英

Custom file instead of docker-compose.yml

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?

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 up -f dockcer-compose.myname1.yml
docker-compose up -f dockcer-compose.myname2.yml

There are two different issues presented in your question:

The reason for getting an error

  1. When running docker-compose up , you must be in a directory that contains docker-compose.yml (or '.yaml ), as indicated by the error you are receiving.
  2. The reason you are getting an error is either because there is no such file in the current directory, or (less likely) the environment variable COMPOSE_FILE is set to something else.

Different names for the docker-compose file

In order to use an alternative file, you can take one of these approaches:

  1. Run docker-compose with the --file argument:
$ docker-compose --help

  -f, --file FILE     Specify an alternate compose file
                      (default: docker-compose.yml)

  1. Set theCOMPOSE_FILE environment variable prior to running any docker-compose command.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM