<p>I have a Docker container that reports this resource usage when running locally:</p>

<pre><code>docker run -i --rm -p 8080:8080 my-application
</code></pre>

<p>As you can see the container uses 10.6MiB:</p>

<pre><code>docker ps -q | xargs  docker stats --no-stream             
CONTAINER ID        NAME                 CPU %               MEM USAGE / LIMIT    MEM %               NET I/O             BLOCK I/O           PIDS
b73afe5ee771        mystifying_neumann   0.00%               10.6MiB / 7.777GiB   0.13%               11.7kB / 2.38kB     0B / 0B             21
</code></pre>

<p>Now I run that container in Openshift, setting the following memory limits:</p>

<pre><code>        resources:
          limits:
            memory: 64Mi
          requests:
            memory: 64Mi
</code></pre>

<p>When the pod starts I would be expecting ~11MiB used of a total of 64MiB. However the container is using 53MiB!!! Why this difference?</p>

<p><a href="https://i.stack.imgur.com/bA4oK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bA4oK.png" alt="enter image description here"></a></p>

<p>I finally found the reason of this difference in these two references:</p>

<p><a href="https://github.com/openshift/origin-web-console/issues/1315" rel="nofollow noreferrer">https://github.com/openshift/origin-web-console/issues/1315</a></p>

<p><a href="https://access.redhat.com/solutions/3639191" rel="nofollow noreferrer">https://access.redhat.com/solutions/3639191</a></p>

<p>Summing up: Docker reports memory as the addition of several elements such as rss and cache:</p>

<p><a href="https://docs.docker.com/config/containers/runmetrics/#metrics-from-cgroups-memory-cpu-block-io" rel="nofollow noreferrer">https://docs.docker.com/config/containers/runmetrics/#metrics-from-cgroups-memory-cpu-block-io</a></p>

<blockquote>
  <p>cache     The amount of memory used by the processes of this control
  group that can be associated precisely with a block on a block device.
  When you read from and write to files on disk, this amount increases.
  This is the case if you use “conventional” I/O (open, read, write
  syscalls) as well as mapped files (with mmap). It also accounts for
  the memory used by tmpfs mounts, though the reasons are unclear.</p>
  
  <p>rss   The amount of memory that doesn’t correspond to anything on disk:
  stacks, heaps, and anonymous memory maps.</p>
</blockquote>

<p>Openshift 3.x reads that information using Heapster and can`t tell appart both types of memory.</p>

<p>If you check the docker stats of the container that is running inside Openshift you will find the expected (lower) value.</p>
