Skip to content

Instantly share code, notes, and snippets.

@digitalfiz
Created July 26, 2016 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save digitalfiz/91fde920233509b66bdee83e8818740a to your computer and use it in GitHub Desktop.
Save digitalfiz/91fde920233509b66bdee83e8818740a to your computer and use it in GitHub Desktop.
Getting memory usage of a docker container in linux
for line in `docker ps | awk ‘{print $1}’ | grep -v CONTAINER`; do docker ps | grep $line | awk ‘{printf $NF” “}’ && echo $(( `cat /sys/fs/cgroup/memory/docker/$line*/memory.usage_in_bytes` / 1024 / 1024 ))MB ; done
mount -t tmpfs cgroup_root /sys/fs/cgroup
mkdir /sys/fs/cgroup/memory
mount -t cgroup memory -o memory /sys/fs/cgroup/memory/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment