Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
List memory usage per Docker container
#!/bin/sh
# Lists memory usage per Docker container
#
# FORMAT:
#
# IMAGE:TAG MEMORY_USAGE CONTAINER ID
for i in `find /sys/fs/cgroup/memory/docker/* -type d`; do
CONTAINER_ID=`echo $i | awk -F'/' '{print $7}'`
MEMORY_USAGE=$((`cat $i/memory.usage_in_bytes`/1024/1024))
CONTAINER_NAME=`docker ps --no-trunc | grep $CONTAINER_ID | awk '{print $2}'`
printf "%30s\t%5sM\t%s\n" $CONTAINER_NAME $MEMORY_USAGE $CONTAINER_ID
done
@pmoust
Copy link
Author

pmoust commented May 28, 2014

pmoust/mongo:v0.2     144M  618f53409bc5821a00a74c27954cb7470021cf8d44d5a0d9c786ce22d7c1e9c4
pmoust/redis:latest    42M  734d7dc2818c80eb485b6ffcdd6d5faa4633dbe0314ebdd54cdf55d62207f54e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment