MCPcopy
hub / github.com/google/cadvisor / getRwLayerID

Function getRwLayerID

container/docker/handler.go:109–124  ·  view source on GitHub ↗
(containerID, storageDir string, sd StorageDriver, dockerVersion []int)

Source from the content-addressed store, hash-verified

107var _ container.ContainerHandler = &containerHandler{}
108
109func getRwLayerID(containerID, storageDir string, sd StorageDriver, dockerVersion []int) (string, error) {
110 const (
111 // Docker version >=1.10.0 have a randomized ID for the root fs of a container.
112 randomizedRWLayerMinorVersion = 10
113 rwLayerIDFile = "mount-id"
114 )
115 if (dockerVersion[0] <= 1) && (dockerVersion[1] < randomizedRWLayerMinorVersion) {
116 return containerID, nil
117 }
118
119 bytes, err := os.ReadFile(path.Join(storageDir, "image", string(sd), "layerdb", "mounts", containerID, rwLayerIDFile))
120 if err != nil {
121 return "", fmt.Errorf("failed to identify the read-write layer ID for container %q. - %v", containerID, err)
122 }
123 return string(bytes), err
124}
125
126// newContainerHandler returns a new container.ContainerHandler
127func newContainerHandler(

Calls 2

ReadFileMethod · 0.80
ErrorfMethod · 0.80

Used in the wild real call sites across dependent graphs

searching dependent graphs…