How can a Docker container tell whether its memory was limited?
<p>I'm using <code>cgget -n --values-only --variable memory.limit_in_bytes /</code> inside a Docker container to see how much memory it is allowed to use as per <code>docker run --memory=X</code>. However, I need to know whether the memory was limited at all, which isn't answered by the command above because it'd just give me a large number in that case (<code>9223372036854771712</code> in my tests).</p>

<p>So, is there any way to tell whether memory was limited at all? I'm looking for solutions that don't involve running <code>docker run</code> in a special way, like mounting files from the host (e.g., <code>/var/...</code>) or passing an environment variable.</p>