Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement #745: Ability to set default project name in YML #3118

Closed
wants to merge 1 commit into from

Conversation

fesor
Copy link

@fesor fesor commented Mar 13, 2016

Added project section in docker compose file, which allows users to define default project name in their yaml files:

version: "2"
project:
    default_name: "example"

This will help teams not to forgot about that. For example in my company i have only 5 project, which uses docker compose, and I already experience some problems since developers sometime forgot to add custom project name.

Name resolution rules

  • Use custom name from -p cli option if provided
  • Use custom name from COMPOSE_NAME env variable if available
  • Use default_name option from project section of yml fileif provided
  • Use basename of project directory as project default name

Multiple compose files

If multiple compose yml files provided, project section will be used only from main one.

docker-compose.yml:

version: "2"
project:
    default_name: foo

docker-compose.override.yml:

version: 2
project:
    default_name: bar

If we start docker-compose as usual (i.e. docker-compose.override.yml will override service definition in main file), then project name will be foo.

But if we change the order of files:

docker-compose -f docker-compose.override.yml -f docker-compose.yml config

then bar will be used as project name.

@fesor fesor force-pushed the persistent_project_name branch from 70fd6f2 to 98f0ddb Compare March 13, 2016 18:29
@fesor fesor force-pushed the persistent_project_name branch 2 times, most recently from a203ff4 to c9202b5 Compare March 13, 2016 18:42
@dnephin
Copy link

dnephin commented Mar 14, 2016

We discussed this a bit recently. Any project_name set in the Compose file should be just a default name, so it looks like the precendence order is correct in this PR. However, it's not clear from the name that it's only a "default", and not actually an override.

We weren't really able to come up with a good way to express this. Some ideas that have been suggested previously are:

  • have a section called project: and make the key default_name: or default_project_name:
  • make a top level key default_project_name:

I think it's going to be important to make it clear that this name is just a default.

@fesor fesor changed the title Implement #745: configurable project name Implement #745: Ability to set default project name in YML Mar 15, 2016
@fesor
Copy link
Author

fesor commented Mar 15, 2016

@dnephin good point.

I think project section gives more space for future changes. In this case I more like default_name option.

version: "2"
project:
    default_name: "app"

What do you think?

@dnephin
Copy link

dnephin commented Mar 15, 2016

I personally like that option

ping @aanand , @shin-

Add `project` section in yml and provide `default_name` option.
This will allow users to specify default project name in YML
and provides more clear difference between default and custom
project names.

Signed-off-by: Sergey Protko <[email protected]>
@fesor fesor force-pushed the persistent_project_name branch from 036f2e5 to ce15283 Compare March 26, 2016 23:17
@GordonTheTurtle
Copy link

Looks like we would not be able to merge this PR because of merge conflicts. Please rebase, fix conflicts, and force push to your branch.

1 similar comment
@GordonTheTurtle
Copy link

Looks like we would not be able to merge this PR because of merge conflicts. Please rebase, fix conflicts, and force push to your branch.

@fesor
Copy link
Author

fesor commented Mar 26, 2016

Closing this in flavor of #3057

@fesor fesor closed this Mar 26, 2016
@adrianolek
Copy link

So was the idea of project name in yml abandoned? #3057 only allows to set project name via .env file.

@fesor
Copy link
Author

fesor commented Apr 29, 2016

@adrianolek well... my implementation doesn't allow to override default name from another docker-compose.yml which makes it just pointless, you could just specify project name in .env and that's do the trick.

Also all other cases that I looked to easily solves via env variables (personally I just specify all this in CI build/deploy job as ENV variables and it works for me). Allowing to override default project name using multiple compose file just creates a lot of edge cases and this should be discussed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants