在docker-compose文件中设置$ PROJECT_NAME [英] Set $PROJECT_NAME in docker-compose file

查看:1709
本文介绍了在docker-compose文件中设置$ PROJECT_NAME的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在多个项目中使用相同的 docker-compose.yml 文件。我真的很懒,所以我不想以 docker-compose -p $ PROJECT_NAME up 开始。

I am using the same docker-compose.yml file for multiple projects. I am really lazy, so I don't want to start them with docker-compose -p $PROJECT_NAME up.

从Docker 17.06.0版开始,是否可以直接在 docker-compose.yml 文件中设置变量?

As of Docker version 17.06.0, is it possible to set the variable directly in the docker-compose.yml file?

推荐答案

现在,我们可以使用 .env 文件以设置自定义项目名称,如下所示:

Right now, we can use the .env file to set the custom project name like this:

COMPOSE_PROJECT_NAME=SOMEPROJECTNAME

它不灵活,但总比没有好。当前,有有关此提案的公开问题

It's not flexible, but it's better than nothing. Currently, there is an open issue regarding this as a proposal.

这篇关于在docker-compose文件中设置$ PROJECT_NAME的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆