-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Compatibility mode #5684
Compatibility mode #5684
Conversation
translating deploy keys to equivalent v2 config if available Enabled using `--compatibility` CLI flag Signed-off-by: Joffrey F <[email protected]>
Signed-off-by: Joffrey F <[email protected]>
cc @mefyl @vdemeester for review 👓 |
But doesn’t the V3 format already support memory and cpu limits? ie; deploy:
resources:
limits:
cpus: '0.50'
memory: 50M
reservations:
cpus: '0.25'
memory: 20M |
Oh; they were ignored by docker compose? Sorry, missed that |
@thaJeztah Yes, the point here is to have a way to account for them in Compose as well. It's behind a flag because we can't really guarantee the behavior will match exactly what you would see with |
Would it make sense make this an option on |
@dnephin it works with |
Wondering; things like |
I want to say no - the secrets emulation is super confusing to users as it is already (see feedback in #4994 for example). I think having users opt into the feature gives us a chance to setup expectations a little better. |
Ah, yes, then 👍 on the flag |
When I executed docker-compose --compatibility config` return this message:
Why flag |
Those options are scheduling options for swarm-mode services (i.e., they don't actually reserve the resources, only make swarm take those into account when scheduling containers on a node). Docker Compose doesn't work with swarm mode (it deploys local containers), so there's no orchestrator to take those limits into account |
For not swarm-mode, how can I manager memory and cpu resources deploying local containers? |
Using the feature described here; the warning that's printed is about cpu reservation; Using this compose file: version: '3.5'
services:
web:
image: nginx:alpine
deploy:
resources:
limits:
cpus: '0.50'
memory: 50M
|
if 'cpus' in resources_dict['limits']: | ||
service_dict['cpus'] = float(resources_dict['limits']['cpus']) | ||
if 'reservations' in resources_dict: | ||
service_dict['mem_reservation'] = resources_dict['reservations'].get('memory') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shin- I just noticed this; this part isn't correct, because --memory-reservation
(although named similar) is something very different than --reserve-memory
on docker service
; see moby/moby#14579
In order to be able to configure memory limit for containers executed with docker-run, compatibility mode has to be used for v3 docker-compose files. For more info, see: docker/compose#4513 docker/compose#5684
https://blog.csdn.net/ZacharyBacon/article/details/121739675 为何不通过cgroup限制资源,现在只是支持swarm模式下,如果是非swarm下,可以通过挂载cgroup的文件来限制容器的资源。感兴趣的话,可以看下我写的这篇文章。 |
So now "limits" cpu/memory can be used with compatibility mode in a v3 file |
@lordraiden this is a 6 year old pull request; docker compose v2 now uses the compose-specification file format which does not use a version, and unifies the v2 and v3 features; docs are located here; https://docs.docker.com/compose/compose-file/ |
Using the
--compatibility
CLI flag, v3 files can be converted to their v2 equivalent, withdeploy
options translated when possible.--compatibility
can be used with all commands.The conversion is a "best effort" attempt and shouldn't be relied on for production deployments.
Fixes #4513