Docker-使用非默认的 yml 文件名组合

我有一个非默认的 docker-compose 文件名(docker-compose-test. yml)。 它只定义了一个服务。

我正在使用“ docker-compose-f docker-compose-test. yml 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

我理解,它是寻找默认的码头组成文件名。是否有一种方法来指定自定义配置文件名在 docker-撰写下来?

66298 次浏览

You should run the docker-compose down command with the same flags that when you started the containers.

docker-compose -f docker-compose-test.yml down

You can create a .env file and add the following:

COMPOSE_FILE=docker-compose-test.yml

If you use multiple files for docker-compose AND a custom name, you should write like this:

docker-compose -f docker-compose.yml -f docker-compose.override.yml -p custom_name down

Note, that the syntax of docker-compose is such that -f needs to be before up/down, and thereafter -d:

docker-compose -f docker-compose.prod.yml up -d

If you put -f after up/down, it doesn't work, and also if you put -d before up/down you get the help display or an error. Down works of course without -d:

docker-compose -f docker-compose.prod.yml down