-
Notifications
You must be signed in to change notification settings - Fork 118
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
Specifying cgroup limits on a child container fails with cgroups v2 #6288
Comments
Hi, this seems to be an error reported by Could you try the docker option |
Thanks for the suggestion - unfortunately I see the same error with that addition option. I'm far from knowledgeable on cgroups, but it felt to me like there's some restriction on child cgroups in cgroupsv2 by default, which needs changing with settings like
|
Hi @pete-woods thanks for this pointer. |
Docker confirmed there is a limitation with runc and the workaround (until Docker fixes this) is to use cgroupsv1 for MacOS v 4.3.0. We're still waiting to hear back when they will have this fixed but they are aware of the issue. |
According to https://docs.docker.com/desktop/release-notes/#bug-fixes-and-minor-changes-12,
should allow you to run newer Docker Desktop with cgroups v1 on mac. |
Hello! Is there a moby ticket representing this work anywhere? Thanks! |
@Scipi can you provide the commands you used on Linux? I couldn't get it to work. Can you share the |
@fredericdalleau
I used the commands in the original post, but for the
I just tried with the cgroupfs driver and it seems the original issue appears
|
@fredericdalleau Gentle ping, is there a moby ticket representing this work? |
@fredericdalleau should we create a ticket on the runc project instead to track this? |
@lifubang @AkihiroSuda this error was added in opencontainers/runc#2390 - do one of you know if this is not possible or if it's something that just was not (yet) implemented in runc? |
So, cgroup v2 has a constraint -- you can only have processes in leaf nodes*. In particular, this means that if you want two containers to be limited by the same set of resources, you have to create these containers as sub-cgroups of a particular cgroup with resources. |
So going back to @thajezteh comment, is this NOT possible at all? |
This is exactly our use case. On our CI platform, we run a "pod-like" construct that shares CPU and RAM limits between all containers in the "pod". We do this by creating a "parent" container with e.g. 2CPUs and 4GiB of RAM limits, noting its container ID, and then starting the other containers by guessing its cgroup path, and specifying that as the parent cgroup. (Of course we would far prefer built-in support for starting a group of containers with a shared resource quota, than our current solution) |
The slightly longer answer to the above; from a conversation I had with @kolyshkin at the time. My (simplified) interpretation of the issue is that; that v2 cgroups do not allow for a cgroup tree to join / become a child of a tree that has a process running in it. In the example case, "container A" is created, which creates its cgroup tree with the container's process running in it. When the second container joins the cgroup it attempts to join as a child of that cgroup, but this is blocked because that cgroup contains the process for container A, so gets refused. Changing this is complicated, and may even require changes in the OCI Runtime Specification; a possibly solution for this would be for containers to always set up a "parent" cgroup without process in it, then put their own group inside it; effectively, each container would become a "pod", and setting resource-constraints would now have to be done on the "wrapper" (parent) cgroup. This is a divergence from the OCI spec as it's currently defined. I was told |
There hasn't been any activity on this issue for a long time. Prevent issues from auto-closing with a /lifecycle stale |
/lifecycle frozen |
Expected behavior
Specifying cgroup limits to a child container should work as expected when using cgroups v2
Actual behavior
Specifying cgroup limits to a child container when using cgroups v2 causes an error
docker: Error response from daemon: failed to create shim: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:385: applying cgroup configuration for process caused: cannot enter cgroupv2 "/sys/fs/cgroup/docker/daf122c11ae7f14b6a8174ec6338e9740f1c26a60b332a6094527ffbfa7f302f" with domain controllers -- it is in domain threaded mode: unknown.
Information
Output of
/Applications/Docker.app/Contents/MacOS/com.docker.diagnose check
Steps to reproduce the behavior
docker info
)docker run --rm -d --name pause -p 8080:80 --ipc=shareable --cpus=1 gcr.io/google_containers/pause-amd64:3.0
docker run --rm --name stress --net=container:pause --ipc=container:pause --pid=container:pause --cgroup-parent="/docker/<parent-id>" --cpus=2 alexeiled/stress-ng --cpu=2
An error is produced:
docker: Error response from daemon: failed to create shim: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:385: applying cgroup configuration for process caused: cannot enter cgroupv2 "/sys/fs/cgroup/docker/daf122c11ae7f14b6a8174ec6338e9740f1c26a60b332a6094527ffbfa7f302f" with domain controllers -- it is in domain threaded mode: unknown.
Running the child container without
--cpu=2
allows the container the work. The failing case also works fine on linux.The text was updated successfully, but these errors were encountered: