-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
allow removing something in docker-compose.override.yml #3729
Comments
Correct. Best practice is to not include anything in |
My problem with your suggestion is that docker-compose.override.yml might not exist (it's an optional file the developer can create locally). I only want to use docker-compose.override.yml to locally customize ports, like this: docker-compose.yml:
docker-compose.override.yml:
This isn't a big deal because this will only result in 80 being exposed twice, once as a random port and once as 32080. I think it would make sense in this case to only expose it as 32080 automatically (without having to specify anything in the override to remove the original config value) |
Facing the same problem. I've got one specific host which shouldn't start the one of the docker containers for given service. Yeah, maybe my |
Did anyone get script to remove ports from docker-compose file ? :) |
Alright, there is no solution so far, so I got a simple port-remover In general I dont think docker-compose should allow to do it, as then logic of merging many files is gonna be complex... |
This was already solved here #3939 |
It's also not possible to removed a service, isn't it? |
Having an "override" thing that cannot do half of the job... well, it's something. |
I'd like to be able to override some services and disable some others. |
Same issue, I'd like to have possibility to remove port, dns, etc in |
Anyone notice that the only thing that you can't do with docker-compose.overide.yml, is to actually override anything! |
I would like to remove some services because I rarely use them on my machine, so I ended up with the following
|
To add two more cents to the pile. It can happen that you pull a docker-compose.yml from another group and want to not run some of what they have turned on. Please add some syntax for removing. |
Three years passed and still nothing? |
Prevents Eleasticsearch, Logstash, and Kibana images from running in local development mode. Approach taken from: docker/compose#3729 (comment) [#166832517] https://www.pivotaltracker.com/story/show/166832517
Stumbled upon this issue when trying to override the |
Same problem here... It seems it's not overriding some values correctly. Can't remove either.
Setting |
If the above saying is true, it means that the inherent parser is not able to just load several dictionaries and then apply the overriding of keys following some arbitrary order, which is not complicated in nature. The truth is that the current design has made a key dependent behaviour. ref https://docs.docker.com/compose/extends/ My feeling is that it would be better to go for a more intuitive behaviour for developers, like that in multiple inheritance cases. The current use case consists of combining multiple yaml files in the same command line, which looks just like a one layer inheritance. The better would even be able to support multiple layer multi-inheritance using some kind of inclusion key word. Also, to specify the case when child will either merge or simply replace, some key words like "super" could hence be interesting to have. "Composition" could be a workaround to achieve the same thing as "inheritance". In the case of docker compose file one may do something similar. The key word "extend" becomes helpful in this case, which may , yet, result in a more verbose compose file. Also, one would need to very carefully craft each file so that things are always extended/override but not removed. |
Needed a small script which removes build and adds image to a docker-compose service. Maybe this helps other building CI scripts as well e.g. removing a service. From my point of view the remove feature should be added to docker-compose overwrite as it decreases user experience of docker-compose a lot. |
Hi Thomas, I wrote a simple script, docker-compose-use, as the basis of my AngelBox toolkit. This makes docker-compose files "composable". You will find this at https://github.com/keithy/sprankle-pod and https://github.com/keithy/angelbox |
@thomaspeitz or just use yq. you can easily edit parts of yaml with it. F.e. Adding image: |
It is ridiculous that the team of "professionals" of |
Any progress on this? |
Just chiming in to say "me too" |
compose-spec/compose-spec#340 has been approved and merged |
Damn, I remember reading this in 2016 and 7 years later it's still nice to know that it got in. |
Yeah! It finally happened! Thank you! |
I feel this is still not enough.
Will remove those ports.
|
@hubertnnn yes indeed, services:
foo:
ports:
- ${HTTP_PORT:-80}:80
- ${HTTPS_PORT:-443}:443 so you can run compose with a local |
I think this is where I was confused too. What if you want to remove a port (or volume, or similar) rather than just replace it? I'm struggling to see how you can actually replace the whole value of ports. |
So how are we supposed to override ports using I have a |
yeah, I'm struggling removing all ports from a Service in the override. (I'm not intending to replace, just remove all ports) In the override, if I do this : version: '3.4'
services:
workflow-app:
ports: !reset I get the error : So I try this : version: '3.4'
services:
workflow-app:
ports: !reset
- "" I get the error : The only work around I've found is to create an entry for some non-existant ports, which is just a mess, like this : version: '3.4'
services:
workflow-app:
ports: !reset
- "9999:9999" What am I missing here? @ndeloof any ideas? TIA |
services:
workflow-app:
ports: !reset [] // empty list won't trigger a parsing error (and please, don't set a |
@ndeloof awesome thanks so much! Thank you for the guidance around the obsolete practice. Much appreciated. |
@ndeloof I just want to check if I understand correctly.
Here, the value
The intention being to remove port 2000, but keep port 1000. That isn't possible at all currently (or anything involving replacing the full list)? |
yes indeed, this isn't yet supported. |
Thanks for clarifying @ndeloof (and so quickly!). It's good at least to know for certain that I'm not missing something, |
Hi @ndeloof
Does it mean you plan to support it in the future? (cannot find an issue for this but I may have missed it). |
feel free to create an issue on github.com/compose-spec/compose-go for this purpose |
My development system has I need the proxy to be used for build time, and I'm careful to use "ARG" in my Dockerfiles for building so that I can use the proxy during build time and exclude it for runtime, but docker compose has other plans. Being able to: I tried using Being able to explicitly tell docker to let me have 100% control of what environment variables get defined in the docker-compose.yml would cut back on a lot of overhead dealing with corporate environments. If someone has created the issue over on the compose-spec/compose-go github, can you please link it here as I would like to add my support for this feature. I have been fighting environment variable proxy garbage off and on for a year and I'm sick of it. I need a solution, like the one proposed above, that works on all OSes regardless of the underlying config. At the docker-compose.yml and docker-compose.override.yml level I ought to be able to definitively nail down the "truth" of how a container is defined and have it be defined that way on any system I run it. |
@quarky42 |
I don't want them to be set. I don't have them set in ~/.docker/config because that will set them in the containers.... Which is what I don't want. On Linux, the solution is to set the environment variables in /etc/systemd/system/dockerd/proxy.conf This works. There is no equivalent for Windows. Having !reset at a block level would ensure that I can create a config that explicitly denies all environment variables. When working on a project shared by multiple developers, it is very important to be able to have a consistent container generation. I want to EXCLUDE all (100%) environment variables at the docker-compose.yml level. Currently, proxy values are being carried into my containers. Having support for !reset on a block level would ensure that only explicitly set values were used. |
Do you have a comparable issue having such variables set when you run a plain |
In short: no, we do not build 30 services across 3 nested projects each with about 10 subprojects each by first building each Dockerfile individually, nor are we interested in doing that. When you have a team of devs using Windows, Linux, and Mac, it is critical to have control at the docker-compose.yml level of what makes it into and doesn't make it into the container. On Linux and Mac, that control is there. On Windows Docker Desktop, I have not found a way to prevent it from embedding proxy info when using the latest version of Docker Desktop. I can get close on Windows, but there is still a variable there that shouldn't be. |
my question was not to use this on a daily basis, but to confirm you only get such a variable issue when building with compose, and a plain |
Thank you for the clarification. I do appreciate it. I will have to build an image manually on the CLI as I don't have anything like that. It'll be Monday before I'm back in the office. The remote servers have a couple manually built images but those are Linux and I know they are good. They weren't at first, but I figured out the use of build args plus the systemd level conf file and that fixed them. Also those get built and tested with a script, so not as much hands on as it could be. |
It works, thanks a lot! I have just an issue with vscode extension: It seems that the schema is missing something https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json ? |
@paolomainardi |
thanks @ndeloof so the issue is with the vscode official docker extension |
It is finally supported from Docker Compose version 2.24.4 and later
Pls check - https://docs.docker.com/compose/compose-file/13-merge/#replace-value |
My usecase is that the base
docker-compose.yml
maps a certain port in theports
section. In mydocker-compose.override.yml
I'd like to change that port since I already have a different service running there on my host.As far as I understand the current implementation it is only possible to add stuff, override extends the other file.
As far as I can tell there is no way to remove an entry. And I can't think of an obvious syntax for it.
The text was updated successfully, but these errors were encountered: