You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 23, 2019. It is now read-only.
Is this expected (or what I am doing wrong) ? And if it is expected, why types.Container even has Mounts []MountPointif it's left empty by ContainerList ?
How to reproduce:
I am running a small test below, which enumerates containers with ContainersList and checks the content of .Mounts, and then does per-container ContainerInspect and checks the content of .Mounts again.
Docker 1.10.3 , Ubuntu 14.04 Kernel 3.13. Engine-API is used via vendoring, taken on March 2
Test run output:
Output refcount using List 0 shows there was 0 local mounts (which is wrong, and I did check and .Mounts all have len 0 in the ContainerList resutl)
Output refcount using Inspect 103 shows all data volume mounts were accurately counted
The test assumes some containers with local volumes; and your counts will obviously vary
try$ ./mounts_check
2016/04/01 16:40:11 Connected to unix:///var/run/docker.sock
2016/04/01 16:40:14 103 containers found
2016/04/01 16:40:14 total refcount: using List 0 using Inspect 103
Test
//// A simple check for Container.Mounts content in engine-api//package main
import (
"github.com/docker/engine-api/client""github.com/docker/engine-api/types""log"
)
const (
apiVersion="v1.22"driverName="local"endPoint="unix:///var/run/docker.sock"
)
funcmain() {
defaultHeaders:=map[string]string{"User-Agent": "engine-api-client-1.0"}
c, err:=client.NewClient(endPoint, apiVersion, nil, defaultHeaders)
iferr!=nil {
log.Printf("Failed to connect to %s, err: %v\n", endPoint, err)
return
}
log.Printf("Connected to %s\n", endPoint)
containers, err:=c.ContainerList(types.ContainerListOptions{
All: true, Size: true,
})
iferr!=nil {
log.Printf("Faild to get containers list (err: %v)\n", err)
return
}
log.Printf("%d containers found\n", len(containers))
refcnt1:=0refcnt2:=0for_, ct:=rangecontainers {
for_, mount:=rangect.Mounts {
ifmount.Driver==driverName {
refcnt1++
}
}
ct_json, err:=c.ContainerInspect(ct.ID)
iferr!=nil {
log.Printf("Inspect failed on %s : %v\n", ct.Names, err)
continue
}
for_, mount:=rangect_json.Mounts {
ifmount.Driver==driverName {
refcnt2++
}
}
}
log.Printf("total refcount: using List %d using Inspect %d\n", refcnt1, refcnt2)
}
The text was updated successfully, but these errors were encountered:
@msterin I think it's expected with the 1.10 daemon. The Mount attribute in the types.Container is populated by the daemon in 1.11 (we added Mounts to ps and the possibility to filter using it).
Using a daemon 1.11.0-rc2 :
$ go run est.go
2016/04/02 10:59:32 Connected to unix:///var/run/docker.sock
2016/04/02 10:59:35 9 containers found
2016/04/02 10:59:35 total refcount: using List 1 using Inspect 1
@vdemeester - thanks ! It does look sloppy to leave a field selectively filled in by some APIs with zero comments and zero doc, but since it's not my misunderstanding of the API but a bug in 1.10 (fixed in 1.11 per your run) I will just stick with ContainerInspect then.
It's more about version than a bug, you talking to a 1.10 daemon with a v1.11 api lin'. It's retro compatib!e so it works, but some field don't get filed 😇
It's more about version than a bug, you talking to a 1.10 daemon with a v1.11 api lin'. It's retro compatib!e so it works, but some field don't get filed
Nice wordsmithing :-) ! On my books, it is still a bug - I am talking to 1.10 with 1.10 API (see below) but it's beyond the point - your post cleared up what's going on so it's all good. Thanks again.
Docker version API version Changes
1.10.x 1.22 API changes
So I thought I was talking to 1.10 daemon with 1.10 API. .Mounts field was added to engine-API in early February and I picked the code in March. I did not see anything in the 1.22 APi definition which indicates that one API fills the filed in, and another does not.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I see the following behavior:
Is this expected (or what I am doing wrong) ? And if it is expected, why
types.Container
even hasMounts []MountPoint
if it's left empty by ContainerList ?How to reproduce:
I am running a small test below, which enumerates containers with ContainersList and checks the content of .Mounts, and then does per-container ContainerInspect and checks the content of .Mounts again.
Docker 1.10.3 , Ubuntu 14.04 Kernel 3.13. Engine-API is used via vendoring, taken on March 2
Test run output:
refcount using List 0
shows there was 0 local mounts (which is wrong, and I did check and .Mounts all have len 0 in the ContainerList resutl)refcount using Inspect 103
shows all data volume mounts were accurately countedThe test assumes some containers with local volumes; and your counts will obviously vary
Test
The text was updated successfully, but these errors were encountered: