3

Just a simple question I googled for a while but found no answer: How can I display only the allocated resources (cpu cores / memory) inside of a Docker container using top / htop and so on?

Kind regards and a nice weekend :)

~ Morph

pdoherty926
  • 9,895
  • 4
  • 37
  • 68
Morph
  • 173
  • 2
  • 5
  • 15

1 Answers1

4

'docker stats' shows cpu/mem/net io usage.

https://docs.docker.com/v1.8/reference/commandline/stats/

'docker ps -s' shows size of containers.

Docker - How to analyze a container's disk usage?

Memory and disk are shared between docker containers so you can expect to see memory and disk use inside a container to show shared resource size + individual container resource size.

Community
  • 1
  • 1
gaoithe
  • 4,218
  • 3
  • 30
  • 38
  • Hi gaoithe and thanks for your response! I know that it's possible to get the stats on the host, but is there a way to let the container show only the limited values in top / htop? – Morph Sep 23 '16 at 23:09
  • 1
    The container will just see all memory and disk, it mostly isn't aware it is a container. top will just show totals. Looking in /proc allows a certain amount of introspection in container. E.g. here http://tuhrig.de/how-to-know-you-are-inside-a-docker-container/ – gaoithe Sep 23 '16 at 23:52
  • 1
    Hi again and thanks a lot! "it mostly isn't aware it is a container." << That was not clear to me until a moment ago. Thank you very much and have a nice weekend :) ~ Morph – Morph Sep 24 '16 at 00:00
  • 1
    This is very good description of the state of /proc and memory introspection on containers and a suggested standard solution. https://fabiokung.com/2014/03/13/memory-inside-linux-containers/ – gaoithe Sep 24 '16 at 00:10
  • Really nice, thanks! :) I'll read everything I can get to learn more about Docker! – Morph Sep 24 '16 at 00:13