Skip to content

Conversation

@shcallaway
Copy link

@shcallaway shcallaway commented Nov 8, 2017

In your docker-compose.override.yml, the overwrite_multivals config option allows you to specify which multivalue fields should be overwritten instead of concatenated with the base.

For example:

services:
  gateway:
    ports:
      - "80"
    overwrite_multivals:
      - ports

I am totally ripping off this guy's idea: #3939

This PR is a work in progress. Todo:

  • compose/config/validation.py
  • Unit tests
  • Documentation

Signed-off-by: Sherwood Callaway <shcallaway@gmail.com>
@shcallaway
Copy link
Author

shcallaway commented Nov 8, 2017

Do users want a generalized overwrite_multivals option? Or do they only care about overwriting ports? I have opened a separate PR for the latter: #5355

@leonaves
Copy link

+1

@drsharp
Copy link

drsharp commented Feb 5, 2018

@shcallaway I would vote for a generalized option...

we have a use case where the depends_on section is different for some of us in development. For example, the base docker compose for a given service we have depends on two cache stores, one for worker jobs and one for key-value storage. In development, we just run a single Redis for both, but we need them separate in non-development environments. It would be nice to be able to override the depends_on section and rewrite it, but currently the overrides just append.

So consider this a vote in favor of something more general than just ports.

note, if I could "fish my wish" it would simply be that whatever key I put in an override would fully override that key, not append. That would mean if I have something like:

services:
  xyz:
    ports:
       - "443:9876"
    depends_on:
      - service-a
      - service-b
      - service-c

and I wanted it to also depend on service-d in my local development, then I'd have my override look like:

services:
  xyz:
    depends_on:
      - service-a
      - service-b
      - service-c
      - service-d

Currently, to just add an extra service, I can just add that one (because it appends) but I would much prefer the flexibility of a per-section overwrite. For example, in the case I mentioned at the start, if the base uses service-a, service-b, and service-c, but I only want to depend on service-a and service-b, then a full per-key overwrite would allow me to set:

services:
  xyz:
    depends_on:
      - service-a
      - service-b

and be good to go.

I know this may be a corner case, but the idea of only appending when it's a list just seems overly constrictive to me.

@d0ruk
Copy link

d0ruk commented Jun 20, 2018

Currently the only (besides the COMPOSE_FILE) solution is;

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

The only difference between the dev and prod configs is some ports arrays. I can just do

docker-compose -f docker-compose.yml up for prod, if this feature merged into upstream.

Anyone?

@nyetwurk
Copy link

Please take this

@robtayl0r
Copy link

+1

@shcallaway
Copy link
Author

Closing because this particular design won't be approved. I may revisit this feature in the future.

@shcallaway shcallaway closed this Jan 11, 2019
@shcallaway shcallaway deleted the overwrite_multivals branch January 11, 2019 01:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants