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

Docker stats is not working when a container is using another container's network #21848

Closed
akalipetis opened this issue Apr 7, 2016 · 10 comments · Fixed by #21904
Closed

Docker stats is not working when a container is using another container's network #21848

akalipetis opened this issue Apr 7, 2016 · 10 comments · Fixed by #21904
Labels
kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed.
Milestone

Comments

@akalipetis
Copy link
Contributor

Output of docker version:

Client:
 Version:      1.10.3
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   20f81dd
 Built:        Thu Mar 10 15:54:52 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.10.3
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   20f81dd
 Built:        Thu Mar 10 15:54:52 2016
 OS/Arch:      linux/amd64

Output of docker info:

Containers: 85
 Running: 45
 Paused: 0
 Stopped: 40
Images: 335
Server Version: 1.10.3
Storage Driver: devicemapper
 Pool Name: docker-data-tpool
 Pool Blocksize: 65.54 kB
 Base Device Size: 5.369 GB
 Backing Filesystem: ext4
 Data file:
 Metadata file:
 Data Space Used: 25.71 GB
 Data Space Total: 102 GB
 Data Space Available: 76.29 GB
 Metadata Space Used: 44.39 MB
 Metadata Space Total: 5.369 GB
 Metadata Space Available: 5.324 GB
 Udev Sync Supported: true
 Deferred Removal Enabled: false
 Deferred Deletion Enabled: false
 Deferred Deleted Device Count: 0
 Library Version: 1.02.77 (2012-10-15)
Execution Driver: native-0.2
Logging Driver: json-file
Plugins:
 Volume: local
 Network: null host bridge
Kernel Version: 3.13.0-83-generic
Operating System: Ubuntu 14.04.4 LTS
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 7.797 GiB
Name: ***
ID: O6WC:EVCN:ZT7X:QS6L:VCTR:Q3B4:QFBJ:2SHH:ZT2F:H3VJ:I5BU:V42M
WARNING: No swap limit support

Additional environment details (AWS, VirtualBox, physical, etc.):

  • AWS
  • AMI: ubuntu-trusty-14.04-amd64-server-20160114.5 (ami-9abea4fb)
  • Instance type: t2.large

Steps to reproduce the issue:

  1. Run a container, i.e. export PAUSE_ID=$(docker run -d -m 10M kubernetes/pause)
  2. Run a container using the network of the previous container, i.e. CHILD_ID=$(docker run -d -m 100M --net container:$PAUSE_ID kubernetes/pause)
  3. See Docker stats docker stats $PAUSE_ID $CHILD_ID

Describe the results you received:

The stats of $CHILD_ID container are all 0s.

Describe the results you expected:

The stats of $CHILD_ID container to be the actual stats it's using.

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

This also happens in my Beta Docker for Mac with version 1.11.0-rc3.

Also, starting a container with docker run -d -m 100M --net=host kubernetes/pause seems to be working fine in my AWS machine, but not in my local Docker Beta environment does not correctly show the memory limit in the stats.

@thaJeztah thaJeztah added the kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. label Apr 7, 2016
@thaJeztah
Copy link
Member

Thanks for reporting and the clear description and way to reproduce 👍

Also, starting a container with docker run -d -m 100M --net=host kubernetes/pause seems to be working fine in my AWS machine, but not in my local Docker Beta environment.

Can you tell me what isn't working on Docker Beta?

@thaJeztah
Copy link
Member

/cc @cpuguy83 you were working on some docker stats for another PR 😇

@bsedat
Copy link

bsedat commented Apr 9, 2016

Running into this as well. There seems to be an associated error in the docker server logs:
time="2016-04-09T00:21:59.431423945Z" level=error msg="collecting stats for 0f76ed50f8096e53e79df9250c4f1723f3d54b849eb96a58093ad47c62e69153: invalid id: " where 0f76ed50f8096e53e79df9250c4f1723f3d54b849eb96a58093ad47c62e69153 is the equivalent of the original requestor's $CHILD_ID.

@akalipetis
Copy link
Contributor Author

Can you tell me what isn't working on Docker Beta?

Sorry for not making this clear @thaJeztah. Starting a container like this docker run -d -m 100M --net=host kubernetes/pause in the Docker for Mac Beta, does not correctly show the memory limit in the stats. I've also updated the description.

@thaJeztah
Copy link
Member

@akalipetis oh, just remembered the Mac beta, is shipping with docker 1.11.0rc3, which contains a bug that doesn't show the memory-limit in stats; it will be fixed in #21853

@yongtang
Copy link
Member

yongtang commented Apr 9, 2016

I did some investigation and it seems that the issue is located in:
https://github.com/docker/docker/blob/6bd429cb2aabfed7a39748aa3fefd047883f893a/daemon/daemon.go#L1539

In this line, a SandboxID will be "" if the container reuses another container's network stack. As a result, an error is returned and the remote API thinks that the container is not running.

I created a pull request #21904 to try to address this issue.

yongtang added a commit to yongtang/docker that referenced this issue Apr 9, 2016
…er's network.

This fix tries to fix the issue in moby#21848 where `docker stats` will not correctly
display the container stats in case the container reuse another container's
network stack.

The issue is that when `stats` is performed, the daemon will check for container
network setting's `SandboxID`. Unfortunately, for containers that reuse another
container's network stack (`NetworkMode.IsConnected()`), SandboxID is not assigned.
Therefore, the daemon thinks the id is invalid and remote API will never return.

This fix tries to resolve the SandboxID by iterating through connected containers
and identify the appropriate SandboxID.

A test case for `stats` remote API has been added to check if `stats` will return
within the timeout.

This fix fixes moby#21848.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
@thaJeztah thaJeztah added this to the 1.12.0 milestone May 13, 2016
@philipn
Copy link

philipn commented Aug 2, 2016

I'm still seeing this, or what appears to be this, in 1.11.1. Here's the output of my docker version:

Client:
 Version:      1.11.1
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   5604cbe
 Built:        Tue Apr 26 23:44:17 2016
 OS/Arch:      darwin/amd64

Server:
 Version:      1.11.1
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   5604cbe
 Built:        Wed Apr 27 00:34:20 2016
 OS/Arch:      linux/amd64

and docker info:

Containers: 42
 Running: 7
 Paused: 0
 Stopped: 35
Images: 297
Server Version: 1.11.1
Storage Driver: aufs
 Root Dir: /mnt/sda1/var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 385
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins: 
 Volume: local
 Network: null host bridge
Kernel Version: 4.4.14-boot2docker
Operating System: Boot2Docker 1.11.1 (TCL 7.1); master : 901340f - Fri Jul  1 22:52:19 UTC 2016
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 1.428 GiB
Name: minikubeVM
ID: RWMA:TPBD:N4RR:ZTHC:2MGE:3FUU:EE3W:2ZXL:WNFP:ILZ2:OKGH:ANEN
Docker Root Dir: /mnt/sda1/var/lib/docker
Debug mode (client): false
Debug mode (server): true
 File Descriptors: 37
 Goroutines: 75
 System Time: 2016-08-02T01:28:34.80135112Z
 EventsListeners: 0
Username: philipn
Registry: https://index.docker.io/v1/
Labels:
 provider=virtualbox

Environment information:

Steps to reproduce:

  • minikube start && eval $(minikube docker-env)
  • docker ps and then pick the kubernetes dashboard container, and run docker stats <id>

Output:

CONTAINER           CPU %               MEM USAGE / LIMIT   MEM %               NET I/O             BLOCK I/O           PIDS
42375920df6b        0.00%               0 B / 0 B           0.00%               0 B / 0 B           0 B / 0 B           0

Doing docker stats on the paused container will show memory usage, but this is non-ideal (and won't show CPU).

@cpuguy83
Copy link
Member

cpuguy83 commented Aug 2, 2016

This is only fixed in 1.12.

@philipn
Copy link

philipn commented Aug 2, 2016

@cpuguy83 Thanks for the quick response! I'll be on the lookout for a fix in 1.12!

jsoriano pushed a commit to jsoriano/docker that referenced this issue Aug 23, 2016
…er's network.

Cherry-pick from upstream (faf2b6f) for 1.10.3

This fix tries to fix the issue in moby#21848 where `docker stats` will not correctly
display the container stats in case the container reuse another container's
network stack.

The issue is that when `stats` is performed, the daemon will check for container
network setting's `SandboxID`. Unfortunately, for containers that reuse another
container's network stack (`NetworkMode.IsConnected()`), SandboxID is not assigned.
Therefore, the daemon thinks the id is invalid and remote API will never return.

This fix tries to resolve the SandboxID by iterating through connected containers
and identify the appropriate SandboxID.

A test case for `stats` remote API has been added to check if `stats` will return
within the timeout.
jsoriano pushed a commit to jsoriano/docker that referenced this issue Aug 23, 2016
…er's network.

This fix tries to fix the issue in moby#21848 where `docker stats` will not correctly
display the container stats in case the container reuse another container's
network stack.

The issue is that when `stats` is performed, the daemon will check for container
network setting's `SandboxID`. Unfortunately, for containers that reuse another
container's network stack (`NetworkMode.IsConnected()`), SandboxID is not assigned.
Therefore, the daemon thinks the id is invalid and remote API will never return.

This fix tries to resolve the SandboxID by iterating through connected containers
and identify the appropriate SandboxID.

A test case for `stats` remote API has been added to check if `stats` will return
within the timeout.

This fix fixes moby#21848.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
WeiZhang555 pushed a commit to WeiZhang555/moby that referenced this issue Nov 25, 2016
…er's network.

This fix tries to fix the issue in moby#21848 where `docker stats` will not correctly
display the container stats in case the container reuse another container's
network stack.

The issue is that when `stats` is performed, the daemon will check for container
network setting's `SandboxID`. Unfortunately, for containers that reuse another
container's network stack (`NetworkMode.IsConnected()`), SandboxID is not assigned.
Therefore, the daemon thinks the id is invalid and remote API will never return.

This fix tries to resolve the SandboxID by iterating through connected containers
and identify the appropriate SandboxID.

A test case for `stats` remote API has been added to check if `stats` will return
within the timeout.

This fix fixes moby#21848.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
@rikatz
Copy link

rikatz commented Dec 8, 2016

I'm having the same issue:

An environment running CoreOS Alpha (with Docker 1.12), Kubernetes 1.4.6 and Network I/O stats are still not being reported to docker stats command / API.

Any idea why this happens?

ocker version
Client:
 Version:      1.12.3
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   34a2ead
 Built:        
 OS/Arch:      linux/amd64

Server:
 Version:      1.12.3
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   34a2ead
 Built:        
 OS/Arch:      linux/amd64
CONTAINER           CPU %               MEM USAGE / LIMIT       MEM %               NET I/O             BLOCK I/O           PIDS
6a5aeae0e78c        0.00%               1.926 MiB / 3.863 GiB   0.05%               0 B / 0 B           0 B / 0 B           2
21f4051387e8        0.00%               1.91 MiB / 3.863 GiB    0.05%               0 B / 0 B           0 B / 0 B           2
bb847cf8e7d0        0.00%               1.926 MiB / 3.863 GiB   0.05%               0 B / 0 B           0 B / 0 B           2
7321cd08f2fe        0.00%               1.945 MiB / 3.863 GiB   0.05%               0 B / 0 B           0 B / 0 B           2
9c624a1a089e        0.00%               2.008 MiB / 3.863 GiB   0.05%               0 B / 0 B           0 B / 0 B           2
ccb78fb10501        0.00%               1.965 MiB / 3.863 GiB   0.05%               0 B / 0 B           0 B / 0 B           2
78fec3c32488        0.00%               1.957 MiB / 3.863 GiB   0.05%               0 B / 0 B           0 B / 0 B           2
d6e8e628c51d        0.00%               1.785 MiB / 3.863 GiB   0.05%               0 B / 0 B           0 B / 0 B           5
a9817f88618d        0.00%               1.688 MiB / 3.863 GiB   0.04%               0 B / 0 B           0 B / 0 B           4
a43a387df36f        0.00%               1.695 MiB / 3.863 GiB   0.04%               0 B / 0 B           0 B / 0 B           4
f4d0b81503d6        0.00%               1.688 MiB / 3.863 GiB   0.04%               0 B / 0 B           0 B / 0 B           4
8fc0b772d8fc        0.00%               1.723 MiB / 3.863 GiB   0.04%               0 B / 0 B           0 B / 0 B           5
15a1d254c511        0.00%               1.738 MiB / 3.863 GiB   0.04%               0 B / 0 B           0 B / 0 B           5
e5105f86e289        0.00%               1.785 MiB / 3.863 GiB   0.05%               0 B / 0 B           0 B / 0 B           6
80fd18b7e67d        0.00%               1.973 MiB / 3.863 GiB   0.05%               0 B / 0 B           0 B / 0 B           2
f827e9b6a67a        0.00%               1.762 MiB / 3.863 GiB   0.04%               0 B / 0 B           0 B / 0 B           5
b01f2bc82546        0.00%               1.926 MiB / 3.863 GiB   0.05%               0 B / 0 B           0 B / 0 B           2
4c5b77acc47f        0.00%               1.922 MiB / 3.863 GiB   0.05%               0 B / 0 B           0 B / 0 B           2
d936f4017f55        0.00%               1.766 MiB / 3.863 GiB   0.04%               0 B / 0 B           0 B / 0 B           5
ba3aa3bcb7f3        0.00%               1.691 MiB / 3.863 GiB   0.04%               0 B / 0 B           0 B / 0 B           6
b99af403ecdb        0.00%               6.863 MiB / 50 MiB      13.73%              0 B / 0 B           0 B / 0 B           9
2295895e6bd7        0.00%               456 KiB / 3.863 GiB     0.01%               0 B / 0 B           0 B / 0 B           1
0e778cd46b40        0.14%               9.102 MiB / 170 MiB     5.35%               0 B / 0 B           0 B / 0 B           10
6868996052d3        0.00%               1.805 MiB / 3.863 GiB   0.05%               0 B / 0 B           0 B / 0 B           7
a8347456d79f        0.20%               12.73 MiB / 3.863 GiB   0.32%               0 B / 0 B           0 B / 0 B           11
1d152dd60238        13.81%              100.1 MiB / 3.863 GiB   2.53%               0 B / 0 B           77.32 MB / 0 B      9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants