Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running "top" command inside docker container #26113

Closed
sourav82 opened this issue Aug 29, 2016 · 2 comments
Closed

Running "top" command inside docker container #26113

sourav82 opened this issue Aug 29, 2016 · 2 comments

Comments

@sourav82
Copy link

sourav82 commented Aug 29, 2016

Output of docker version:

Client:
 Version:      1.11.2
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   b9f10c9
 Built:        Wed Jun  1 21:47:50 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.11.2
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   b9f10c9
 Built:        Wed Jun  1 21:47:50 2016
 OS/Arch:      linux/amd64

Output of docker info:

Containers: 4
 Running: 2
 Paused: 0
 Stopped: 2
Images: 21
Server Version: 1.11.2
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 110
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins: 
 Volume: local
 Network: host bridge null
Kernel Version: 3.19.0-25-generic
Operating System: Ubuntu 14.04.4 LTS
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 1.946 GiB
Name: ubuntu
ID: GQA6:C24M:QCWL:XELO:3V5I:XSW7:7ONJ:SLW2:R64S:R6AI:AEN6:MCEP
Docker Root Dir: /var/lib/docker
Debug mode (client): false
Debug mode (server): false
Registry: https://index.docker.io/v1/
WARNING: No swap limit support

Steps to reproduce the issue:
1.

docker run -it ubuntu /bin/bash
  1. Inside the container created in step 1, run "top"command

Describe the results you received:

top - 18:03:52 up 17:37,  0 users,  load average: 0.35, 0.25, 0.25
Tasks:   2 total,   1 running,   1 sleeping,   0 stopped,   0 zombie
%Cpu(s): 10.6 us,  5.6 sy,  0.0 ni, 83.8 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem:   2040836 total,  1905172 used,   135664 free,   126276 buffers
KiB Swap:   522236 total,       24 used,   522212 free.  1195708 cached Mem

  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND       
    1 root      20   0   18180   3272   2784 S  0.0  0.2   0:00.21 bash          
   15 root      20   0   19880   2400   2044 R  0.0  0.1   0:00.80 top    

Describe the results you expected:

Compare %Cpu(s) in the 3rd line of output of "top"command and the total %CPU of each process inside the container. %Cpu(s) should be total %CPU used by each process (which is 0 in this case).

Additional information you deem important (e.g. issue happens only occasionally):

What is the %Cpu(s) count and how is it different from total %CPU used by each process inside the container?

@mYmNeo
Copy link
Contributor

mYmNeo commented Aug 30, 2016

top read /proc/stat to show the %Cpu field, and it is not isolated and difficult to do by docker.

@sourav82
Copy link
Author

Well, as I know container provides file system isolation as well. I could see /proc/stat inside container also. So, wondering how the namespaces are implemented in /proc file system. Any link in understanding it will be very helpful.

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

No branches or pull requests

4 participants