{"action":"created","issue":{"url":"https://api.github.com/repos/docker/docker/issues/12394","labels_url":"https://api.github.com/repos/docker/docker/issues/12394/labels{/name}","comments_url":"https://api.github.com/repos/docker/docker/issues/12394/comments","events_url":"https://api.github.com/repos/docker/docker/issues/12394/events","html_url":"https://github.com/docker/docker/issues/12394","id":68621526,"number":12394,"title":"Can't determine Memory limits/usage from inside a container","user":{"login":"jonquark","id":1771856,"avatar_url":"https://avatars.githubusercontent.com/u/1771856?v=3","gravatar_id":"","url":"https://api.github.com/users/jonquark","html_url":"https://github.com/jonquark","followers_url":"https://api.github.com/users/jonquark/followers","following_url":"https://api.github.com/users/jonquark/following{/other_user}","gists_url":"https://api.github.com/users/jonquark/gists{/gist_id}","starred_url":"https://api.github.com/users/jonquark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonquark/subscriptions","organizations_url":"https://api.github.com/users/jonquark/orgs","repos_url":"https://api.github.com/users/jonquark/repos","events_url":"https://api.github.com/users/jonquark/events{/privacy}","received_events_url":"https://api.github.com/users/jonquark/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-04-15T09:08:28Z","updated_at":"2015-04-16T10:47:30Z","closed_at":null,"body":"When running e.g. an in-memory database inside a container it would be incredibly useful to be able to monitor memory usage and limits from inside the container in order to prioritize and cap certain classes of memory usage in low memory situations.\r\n\r\nI'm aware there are some hacky work arounds (are there any I'm missing?):\r\n\r\n1) Give the container access to /proc/self/cgroup as a volume:\r\n docker run -v /sys/fs/cgroup:/sys/fs/cgroup -it --name groupmeminfo -m 4g  fedora:latest /bin/bash\r\n\r\nThen in the container I can see the limit and our usage:\r\nbash-4.3# more /proc/self/cgroup | grep memory\r\n4:memory:/system.slice/docker-898b44c4a066d2dc6343c21d8a5b7c6a77079367d23bcde8c88be0eb204d3a1e.scope\r\nbash-4.3#  more /sys/fs/cgroup/memory/system.slice/docker-898b44c4a066d2dc6343c21d8a5b7c6a77079367d23bcde8c88be0eb204d3a1e.scope/memory.limit_in_bytes\r\n4294967296\r\nbash-4.3# more /sys/fs/cgroup/memory/system.slice/docker-898b44c4a066d2dc6343c21d8a5b7c6a77079367d23bcde8c88be0eb204d3a1e.scope/memory.usage_in_bytes\r\n5013504\r\n\r\n2) If the container is privileged you can mount the cgroup information:\r\nmount -n -t cgroup -o memory cgroup /tmp/memory\r\n\r\nBut a more straight forward mechanism that didn't represent a security risk and didn't require extra complexity in running the container would be really handy.\r\n"},"comment":{"url":"https://api.github.com/repos/docker/docker/issues/comments/93706074","html_url":"https://github.com/docker/docker/issues/12394#issuecomment-93706074","issue_url":"https://api.github.com/repos/docker/docker/issues/12394","id":93706074,"user":{"login":"jonquark","id":1771856,"avatar_url":"https://avatars.githubusercontent.com/u/1771856?v=3","gravatar_id":"","url":"https://api.github.com/users/jonquark","html_url":"https://github.com/jonquark","followers_url":"https://api.github.com/users/jonquark/followers","following_url":"https://api.github.com/users/jonquark/following{/other_user}","gists_url":"https://api.github.com/users/jonquark/gists{/gist_id}","starred_url":"https://api.github.com/users/jonquark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonquark/subscriptions","organizations_url":"https://api.github.com/users/jonquark/orgs","repos_url":"https://api.github.com/users/jonquark/repos","events_url":"https://api.github.com/users/jonquark/events{/privacy}","received_events_url":"https://api.github.com/users/jonquark/received_events","type":"User","site_admin":false},"created_at":"2015-04-16T10:47:30Z","updated_at":"2015-04-16T10:47:30Z","body":"@hqhq  Thanks for the info, that (or an outcome to docker/docker#8427  which I found via your link) would address this."}}