title: Virtual cgroups inside docker
body: <p>im trying to virtualize a slurm cluster with docker containers. There are implementations available on github, but as far as I have seen they use gpid as ProcTracktype. For me, these clusters fail when receiving <code>sbatch</code> jobs. I have implemented my own version with a newer slurm version, and here the sbatch job results in a node in state 'drain'. My assumption after reading the <a href="https://slurm.schedmd.com/slurm.conf.html" rel="nofollow noreferrer">slurm.conf</a>, and why im trying to virtualize cgroups inside the containers, is that the <code>sbatch</code> command forks a child process and gpid and the slurmstepd fail to track this new process. <code>srun</code> works just fine.</p>
  <p>Ive come across this post <a href="https://stackoverflow.com/questions/32534203/mounting-cgroups-inside-a-docker-container">Mounting cgroups inside a docker container</a> , and tried <code>lxcfs</code>. Here, after installation i tried mounting the <code>/var/lib/lxcfs/proc/*</code> directories into the container. Something like</p>
  <pre><code>sudo docker run -it -m 256m \                   
        -v /var/lib/lxcfs/proc/cpuinfo:/proc/cpuinfo:rw \
        -v /var/lib/lxcfs/proc/diskstats:/proc/diskstats:rw \
        -v /var/lib/lxcfs/proc/meminfo:/proc/meminfo:rw \
        -v /var/lib/lxcfs/proc/stat:/proc/stat:rw \
        -v /var/lib/lxcfs/proc/swaps:/proc/swaps:rw \
        -v /var/lib/lxcfs/proc/uptime:/proc/uptime:rw \
        centos:7 /bin/bash
  </code></pre>
  <p>This resulted in the <em>container</em> running in their own cgroup. how do i use this cgroup for inside the container? how do i add the <code>freezer</code> group?</p>
  <p>I also looked briefly into <a href="https://www.man7.org/linux/man-pages/man7/cgroup_namespaces.7.html" rel="nofollow noreferrer">cgroup_namespaces</a>, but i understand it as another approach to achieve the same result as the above mentioned <code>lxcfs</code>.</p>
  <p>I have a feeling im missing something pretty elementary, i would greatly appreciate a pointer into the right direction or a small example.</p>
  <p>Thanks</p>