title: Docker and CPU Priority when applying CPU Hogs
body: <p>I've run into something that I cannot quite wrap my head around so I thought I'd turn to smarter minds than mine.</p>
  
  <p>My problem is that I'm trying to figure out how Docker interacts with the Host CPU and which of Docker and Host have priority use over the resources. I want the CPU usage of the host to take priority over the container.</p>
  
  <p>What I have done so far is I started a regular Ubuntu container and I monitor the performance of that container with cAdvisor. I then ran a CPU hog inside the container using the linux stress tool, hogging all cores.</p>
  
  <pre><code>stress -c 8
  </code></pre>
  
  <p>After confirming that the container did indeed use 100% CPU I ran the same command on the host hogging all 8 cores. What I expected to see was that that container's CPU usage would drop to close to 0% since the host was now using all the resources. What I instead saw was the following:</p>
  
  <p><a href="https://i.stack.imgur.com/DokQ5.png" rel="nofollow">CPU Usage of Docker Container</a></p>
  
  <p>So it would seem the container and the Host evenly share the CPU resources. I've also tried running the stress tool on the host with a niceness value of -20 with the same result as above.</p>
  
  <p>Is there any way setting CPU priority to the host so that Docker container would use almost nothing of the CPU resources when the host was using all of them?</p>
  
  <p>Thankful for any help I can get!</p>