title: Docker CPU percentage
body: <p>Is there any way that I can get the cpu percentage inside docker container and not outside of it?! <code>docker stats DOCKER_ID</code> shows the percentage which is exactly what I need but I need it as variable. I need to get cpu percentage inside the container itself and do some operation with it. 
  I have looked into different stuff such as cgroup and docker rest API, but they do not provide cpu percentage. If there is a way to get the cpu percentage inside the container and not outside of it will be perfect. I found one solution provided by someone in below link, which is still outside the container by the rest api, however I did not really get it how to calculate the percentage. </p>
  
  <p><a href="https://stackoverflow.com/questions/30271942/get-docker-container-cpu-usage-as-percentage">Get Docker Container CPU Usage as Percentage</a> </p>