Skip to content
This repository has been archived by the owner on Feb 1, 2021. It is now read-only.

New label to limit the number of containers per node #1734

Closed
ottes opened this issue Feb 2, 2016 · 6 comments
Closed

New label to limit the number of containers per node #1734

ottes opened this issue Feb 2, 2016 · 6 comments

Comments

@ottes
Copy link

ottes commented Feb 2, 2016

just as discussed in #534 i would need to have a label (or something like this) to limit the number of containers per node.
What about something like com.docker.containersmax oder com.docker.swarm.maxcontainers?
It should be absolutely CPU-/Memory-/Somethingelse-independent.
When no node is found, the "error" should be in the same manner like the error, when no node with that port or constraint is found, something beginning with "unable to find a node ...".

I would help, but my go experience is like zero, maybe i've got the time end of next week, to help a bit with this

@dongluochen
Copy link
Contributor

@xFragger I'm not very sure about CPU/Memory/Somethingelse-independent. Container clustering is about resource utilization and your case seems to fit in that. I had a similar case and I used memory limit to do it. I can only run 4 instances of the following command to use up 4 GB memory on the node.

dchen@vm4:~$ ./docker -H vm2:2372 run  -m 1G -d busybox sh
de884da33e794b3b507a9bac62a8650196e9cc83e4f048127fbcd06b3313e54c
dchen@vm4:~$ ./docker -H vm2:2372 info
Containers: 18
 Running: 0
 Paused: 0
 Stopped: 18
Images: 19
Role: primary
Strategy: spread
Filters: health, port, dependency, affinity, constraint
Nodes: 1
 vm3: xxx.xxx.xxx.xxx:4444
  └ Status: Healthy
  └ Containers: 18
  └ Reserved CPUs: 1 / 2
  └ Reserved Memory: 1 GiB / 4.053 GiB
  └ Labels: executiondriver=native-0.2, kernelversion=3.19.0-25-generic, operatingsystem=Ubuntu 14.04.3 LTS, storagedriver=aufs
  └ Error: (none)
  └ UpdatedAt: 2016-02-03T21:44:12Z
Plugins: 
 Volume: 
 Network: 
Kernel Version: 3.19.0-25-generic
Operating System: linux
Architecture: amd64
CPUs: 2
Total Memory: 4.053 GiB
Name: vm2
Experimental: true

@ottes
Copy link
Author

ottes commented Feb 4, 2016

But with this, i limit the memory per container to 1GB, i don't want to do this.

I'm sure, that that is exactly what i need: a max of n containers per node, controlled by a label at the node

@ottes
Copy link
Author

ottes commented Feb 4, 2016

Another more general solution could be to allow <, >, >= and <= as possible constraint expressions and bring in some "variables" to compare to

I would label all my instances with a maxContainerCount label und check at launch time by
-e constraint:maxContainerCount<$node.containers or something like that

@sah4ez
Copy link

sah4ez commented Aug 20, 2017

Hi!
When I use: maxContainerCount<$node.containers in my docker-compose.yml I had error:

Error response from daemon: rpc error: code = 2 desc = constraint expected one operator from ==, !=

Do you have idea how it fix?

@Shashwatsh
Copy link

Any updates on this?

@gdoermann
Copy link

This seems like a pretty important thing, especially if you do not have the exact same hardware when processing jobs... is this something that could be added to swarm?

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

No branches or pull requests

7 participants