GithubHelp home page GithubHelp logo

Comments (55)

igor-lemon avatar igor-lemon commented on July 28, 2024 7

Right now we can use .env file with custom project name and set
COMPOSE_PROJECT_NAME=SOMEPROJECTNAME
It's not flexible but it's better than nothing.

from compose.

wcarmon avatar wcarmon commented on July 28, 2024 4

+2

from compose.

jderusse avatar jderusse commented on July 28, 2024 3

The problem with your proposals, is that you'r mixing project configuration and service declaration. it's less readable and adding a keyword (projet or .project) can break backward compatibility.

I realy thinks it's time for docker-compose to improve it schema by adding a top level structure wich contains services.

containers:
  web:
    ...
  db:
    ...

With such structure, we'll be able to improve the schema like

schema-version: 1.1
project_name: foo
containers:
  web:
    ...
  db:
    ...

or

schema-version: 2.0
project: 
  name: foo
  default_env_file: ./bar
containers:
  web:
    ...
  db:
    ...

Notice the property schema-version which help us keep backword compatibilities with schema evolutions.
And to keep BC with current schema, in compose/project.py::from_config

    @classmethod
    def from_config(cls, name, config, client):
        if 'schema-version' not in config or not isinstance(config['schema-version'], basestring)
            config = {
                'schema-version': '1.0',
                'containers': config
            }
        dicts = []
        for service_name, service in list(config.containers.items()):
            if not isinstance(service, dict):
                raise ConfigurationError('Service "%s" doesn\'t have any configuration options. All top level keys in your docker-compose.yml must map to a dictionary of configuration options.' % service_name)
            service['name'] = service_name
            dicts.append(service)
        return cls.from_dicts(name, dicts, client)

If I've time, i'll work on a patch proposal in the nexts days.

from compose.

DrMeers avatar DrMeers commented on July 28, 2024 3

Yes but it makes sense to allow the project name to be configured in the config file to avoid having to set it on the command line or environment?

from compose.

dnephin avatar dnephin commented on July 28, 2024 1

The project name is already configurable from command line or environment variable (-p or COMPOSE_PROJECT_NAME)

from compose.

MadWombat avatar MadWombat commented on July 28, 2024 1

+1 maybe make it version: "3" or something

from compose.

jpringle03 avatar jpringle03 commented on July 28, 2024 1

+1 I would definitely love to see this.

from compose.

aanand avatar aanand commented on July 28, 2024

I don't want to give up top-level services without a fight. Perhaps everything other than service configuration could go in a top-level key with a special name:

PROJECT:
  name: myapp

web:
  ...

db:
  ...

from compose.

bfirsh avatar bfirsh commented on July 28, 2024
.project:
  name: myapp

web:
  ...

db:
  ...

maybe

from compose.

bfirsh avatar bfirsh commented on July 28, 2024

or maybe services is a reserved service name and you can either do

name: myapp
services:
  web:
    ...

  db:
    ...

or

web:
  ...

db:
  ...

depending on whether you need extra config. But that's a bit gross.

I think I quite like the idea of adding a top-level "services" key.

from compose.

sherzberg avatar sherzberg commented on July 28, 2024

+1 on a special key like @aanand mentioned. I would like to do global environment variables here too :)

from compose.

djmaze avatar djmaze commented on July 28, 2024

+1 for top-level name and services keys. You could just make a new major release so backwards compatibility is not mandatory ;)

I also like the idea of global environment variables. So you could e.g. give credentials to a database container (for setting up the database & user) as well as all consuming services. Those would be defined in a top-level environment entry.

from compose.

thaJeztah avatar thaJeztah commented on July 28, 2024

Being able to specify the project-name manually (and not rely on the name of the directory) is quite important;

  • using our standard project-structure, the most logical location for the fig-file to resort in will be named the same for all our projects.
  • we're planning on using a shared docker host for our developers to work on. Multiple developers will work on their own instance of a project, so they should be able to provide a unique name for their instance of the project.

besides being able to specify the project-name inside fig.yml, fig should also take a parameter to override this, e.g. fig up -d --project-name=${USER}-my-project

from compose.

thomasf avatar thomasf commented on July 28, 2024

An alternative solution to having a special global key is to support two streams in fig.yaml.

Something like this:

project-name: something
---

db: 
  ...

app:
 ...

It might not be a good idea to attach semantics to location in the stream, I just wanted to throw it in the suggestion bowl.

from compose.

dnephin avatar dnephin commented on July 28, 2024

+1 for a single special key for non-service or "meta" stuff. This also came up in #210, and will be necessary for #318.

from compose.

dnephin avatar dnephin commented on July 28, 2024

@thomasf I'm not sure how many yaml parses support multiple streams. I tried it out with pyyaml and I got ComposerError: expected a single document in the stream.

from compose.

thomasf avatar thomasf commented on July 28, 2024

Its supported according to the docs by using load_all

http://pyyaml.org/wiki/PyYAMLDocumentation#LoadingYAML

from compose.

shuron avatar shuron commented on July 28, 2024

What about several (related) projects in one fig.yml?
I wan't to manage them all in one fig. Cause to me fig define something like everything on one host or vm. So some kine of basic namespacing should be here. At least i wanna have a possibility to give containers custom names. ( run --name=custom).

from compose.

dnephin avatar dnephin commented on July 28, 2024

@aanand do you see the group.yml format in https://gist.github.com/aanand/9e7ac7185ffd64c1a91a changing much?

I'd like to add support for that format to fig so that users can migrate to the new format ahead of any docker release with this support (to make the transition smoother). That change should also resolve this issue.

If you think it's still likely to change, I can hold off until it's more stable.

from compose.

aanand avatar aanand commented on July 28, 2024

@dnephin It should be considered unstable, so no adding support just yet. Input appreciated on the format itself - I'm actually somewhat unconvinced about putting the group name in the file, because it makes the whole thing less portable. Perhaps it should go in a separate, unversioned file.

from compose.

mikehaertl avatar mikehaertl commented on July 28, 2024

+1

Any news on this? There was an interesting suggestion by @jderusse here, which i like very much:
#745 (comment)

from compose.

yegortokmakov avatar yegortokmakov commented on July 28, 2024

I have two projects that are using docker compose, one dependent on the other. For this use-case it will be great to have something like dependent projects:

schema-version: 2.0
project: 
  name: foo
  default_env_file: ./bar
require:
  project2:
    config: PATH | URL
    services:
      - serv1
      - serv2
    detached: true
containers:
  web:
    ...
  db:
    ...

I am posting there because it seems like relative to #1233
Does it makes sense? If yes, I will make it based on @jderusse code.

from compose.

dnephin avatar dnephin commented on July 28, 2024

This sounds a lot like #318

from compose.

phazei avatar phazei commented on July 28, 2024

+1
It's a bother when dealing with many projects and many compose files to reply on "COMPOSE_PROJECT_NAME" or -p
Should go in the config.

from compose.

SonicGD avatar SonicGD commented on July 28, 2024

+1

from compose.

dcosson avatar dcosson commented on July 28, 2024

+1

from compose.

pastuhov avatar pastuhov commented on July 28, 2024

+1

from compose.

pahanini avatar pahanini commented on July 28, 2024

+1

from compose.

royingantaginting avatar royingantaginting commented on July 28, 2024

+1

from compose.

Filirom1 avatar Filirom1 commented on July 28, 2024

+1

from compose.

mwr avatar mwr commented on July 28, 2024

+1

from compose.

boedy avatar boedy commented on July 28, 2024

+1

from compose.

koddo avatar koddo commented on July 28, 2024

Hello. I know this is not a solution.
Right now I use this trivial script to unclutter the command line a bit:

#!/usr/bin/env bash

docker-compose --project-name whatever "$@"

Then:

$ docker-compose-whatever.sh up -d
$ docker-compose-whatever.sh logs

from compose.

jderusse avatar jderusse commented on July 28, 2024

Could works... until you manage dozen of projects

from compose.

koddo avatar koddo commented on July 28, 2024

jderusse, I would write a line to make it take the project name from something like ./docker-compose-project-name. Just a quick and dirty fix until the option we all ask for is added eventually.

from compose.

koddo avatar koddo commented on July 28, 2024

What about this?

#!/usr/bin/env bash

PRJ=$(head -n 1 ./docker-compose-project-name)
docker-compose --project-name "$PRJ" "$@"

from compose.

neilsarkar avatar neilsarkar commented on July 28, 2024

+1

from compose.

tkuben avatar tkuben commented on July 28, 2024

Any update on this? I would like a way to name the final image either via command line or via yml file.

from compose.

bachi76 avatar bachi76 commented on July 28, 2024

+1

from compose.

ChrisPearce avatar ChrisPearce commented on July 28, 2024

+1 for being able to set this in the docker-compose.yml file

from compose.

alekbarszczewski avatar alekbarszczewski commented on July 28, 2024

+1

from compose.

dnephin avatar dnephin commented on July 28, 2024

Let's continue this in #745. The project name is configurable, now we just need a persistent configuration.

from compose.

temirov avatar temirov commented on July 28, 2024

👍

from compose.

kenylieou avatar kenylieou commented on July 28, 2024

+1

from compose.

droidlabour avatar droidlabour commented on July 28, 2024

+1

from compose.

deiucanta avatar deiucanta commented on July 28, 2024

+1

from compose.

eugenesia avatar eugenesia commented on July 28, 2024

+1

from compose.

edrzmr avatar edrzmr commented on July 28, 2024

+1

from compose.

ameoba32 avatar ameoba32 commented on July 28, 2024

+1

from compose.

igor-lemon avatar igor-lemon commented on July 28, 2024

+1

from compose.

vimalloc avatar vimalloc commented on July 28, 2024

+1

from compose.

richardbrinkman avatar richardbrinkman commented on July 28, 2024

+1

from compose.

phoenixsampras avatar phoenixsampras commented on July 28, 2024

+1

from compose.

jmthvt avatar jmthvt commented on July 28, 2024

+1

from compose.

thaJeztah avatar thaJeztah commented on July 28, 2024

I'm locking the conversation on this issue; the -p / --project-name and COMPOSE_PROJECT_NAME options have been implemented over two years ago, and a follow-up discussion can be found in #745

from compose.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.