Memory usage of Docker containers

I am using Docker to run some containerized apps. I am interested in measuring how much resources they consume (as far as regarding CPU and Memory usage).

Is there any way to measure the resources consumed by Docker containers like RAM & CPU usage?

  • Docker - Running nginx as a proxy for Redmine
  • How to get exact date for docker images?
  • Can't install s3fs-fuse(yum fuse-devel version issue) and can't install libfuse(./config missing issue)
  • Docker didn't forward the port from web service
  • Do docker containers retain file changes?
  • how can I get the AUFS kernel module on a Google Compute Engine (GCE) kernel?
  • Thank you.

  • Installation in Intel System Studio error
  • Docker: How to deploy a vsftpd instance?
  • Docker Postgres data volume on the host
  • dante-sever fail to bind ip by interface name in docker container
  • How to use docker to create linux images per user on the same domain
  • nginx proxy from port 80 to other ports
  • 3 Solutions collect form web for “Memory usage of Docker containers”

    Update: See @Adrian Mouat’s answer below as docker now supports docker stats!

    There isn’t a way to do this that’s built into docker in the current version. Future versions will support this via an api or plugin.

    It does look like there’s an lxc project that you should be able to use to track CPU and Memory.

    You can get this from docker stats e.g:

    $ docker stats --no-stream
    CONTAINER           CPU %               MEM USAGE / LIMIT   MEM %               NET I/O             BLOCK I/O             PIDS
    6b5c0fcfa7d4        0.13%               2.203 MiB / 4 MiB   55.08%              5.223 kB / 648 B    102.4 kB / 876.5 kB   3

    Also, you can read resource metrics directly from cgroups.
    See example below (I am running on Debian Jessie and docker 1.2)

    > docker ps -q
    > ls /sys/fs/cgroup/memory/system.slice/ | grep docker-afa03c363af5
    > cd docker-afa03c363af54815d721d938e01fe4cb2debc4f6c15ebff1851e20f6cde3ae0e.scope
    > cat memory.usage_in_bytes
    > cat memory.limit_in_bytes
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.