[英]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. 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:尝试运行docker-compose up
出现错误:
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.所以我想知道 Docker 项目是否可以在没有docker-compose.yml
文件的情况下工作,如果是,应该满足什么条件。 Maybe that's the matter of some specific version or environment?也许这是某些特定版本或环境的问题?
https://docs.docker.com/compose/reference/ https://docs.docker.com/compose/reference/
"Options: -f, --file FILE Specify an alternate compose file (default: docker-compose.yml)" “选项:-f, --file FILE 指定一个备用的撰写文件(默认值: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:您的问题中有两个不同的问题:
docker-compose up
, you must be in a directory that contains docker-compose.yml
(or '.yaml
), as indicated by the error you are receiving.运行docker-compose up
,您必须位于包含docker-compose.yml
(或'.yaml
)的目录中,如您收到的错误所示。COMPOSE_FILE
is set to something else.您收到错误的原因是因为当前目录中没有这样的文件,或者(不太可能)环境变量COMPOSE_FILE
设置为其他值。In order to use an alternative file, you can take one of these approaches:为了使用替代文件,您可以采用以下方法之一:
docker-compose
with the --file
argument:使用--file
参数运行docker-compose
:$ 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.在运行任何docker-compose
命令之前设置COMPOSE_FILE
环境变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.