mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #21370 from tonistiigi/expose-layer-ids
Expose RootFS in image inspect
This commit is contained in:
commit
694b32df51
5 changed files with 45 additions and 2 deletions
|
@ -1164,6 +1164,7 @@ func (daemon *Daemon) LookupImage(name string) (*types.ImageInspect, error) {
|
|||
Os: img.OS,
|
||||
Size: size,
|
||||
VirtualSize: size, // TODO: field unused, deprecate
|
||||
RootFS: rootFSToAPIType(img.RootFS),
|
||||
}
|
||||
|
||||
imageInspect.GraphDriver.Name = daemon.GraphDriverName()
|
||||
|
|
|
@ -1097,3 +1097,14 @@ func (daemon *Daemon) stats(c *container.Container) (*types.StatsJSON, error) {
|
|||
func (daemon *Daemon) setDefaultIsolation() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func rootFSToAPIType(rootfs *image.RootFS) types.RootFS {
|
||||
var layers []string
|
||||
for _, l := range rootfs.DiffIDs {
|
||||
layers = append(layers, l.String())
|
||||
}
|
||||
return types.RootFS{
|
||||
Type: rootfs.Type,
|
||||
Layers: layers,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -453,3 +453,15 @@ func (daemon *Daemon) setDefaultIsolation() error {
|
|||
logrus.Infof("Windows default isolation mode: %s", daemon.defaultIsolation)
|
||||
return nil
|
||||
}
|
||||
|
||||
func rootFSToAPIType(rootfs *image.RootFS) types.RootFS {
|
||||
var layers []string
|
||||
for _, l := range rootfs.DiffIDs {
|
||||
layers = append(layers, l.String())
|
||||
}
|
||||
return types.RootFS{
|
||||
Type: rootfs.Type,
|
||||
Layers: layers,
|
||||
BaseLayer: rootfs.BaseLayer,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1790,12 +1790,12 @@ Return low-level information on the image `name`
|
|||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"Id" : "85f05633ddc1c50679be2b16a0479ab6f7637f8884e0cfe0f4d20e1ebb3d6e7c",
|
||||
"Id" : "sha256:85f05633ddc1c50679be2b16a0479ab6f7637f8884e0cfe0f4d20e1ebb3d6e7c",
|
||||
"Container" : "cb91e48a60d01f1e27028b4fc6819f4f290b3cf12496c8176ec714d0d390984a",
|
||||
"Comment" : "",
|
||||
"Os" : "linux",
|
||||
"Architecture" : "amd64",
|
||||
"Parent" : "91e54dfb11794fad694460162bf0cb0a4fa710cfa3f60979c177d920813e267c",
|
||||
"Parent" : "sha256:91e54dfb11794fad694460162bf0cb0a4fa710cfa3f60979c177d920813e267c",
|
||||
"ContainerConfig" : {
|
||||
"Tty" : false,
|
||||
"Hostname" : "e611e15f9c9d",
|
||||
|
@ -1876,6 +1876,13 @@ Return low-level information on the image `name`
|
|||
"AttachStderr" : false,
|
||||
"WorkingDir" : "",
|
||||
"User" : ""
|
||||
},
|
||||
"RootFS": {
|
||||
"Type": "layers",
|
||||
"Layers": [
|
||||
"sha256:1834950e52ce4d5a88a1bbd131c537f4d0e56d10ff0dd69e66be3b7dfa9df7e6",
|
||||
"sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -379,3 +379,15 @@ func (s *DockerSuite) TestInspectContainerNetworkCustom(c *check.C) {
|
|||
out = inspectField(c, "container1", "NetworkSettings.Networks.net1.NetworkID")
|
||||
c.Assert(strings.TrimSpace(out), checker.Equals, strings.TrimSpace(netOut))
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestInspectRootFS(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
out, _, err := dockerCmdWithError("inspect", "busybox")
|
||||
c.Assert(err, check.IsNil)
|
||||
|
||||
var imageJSON []types.ImageInspect
|
||||
err = json.Unmarshal([]byte(out), &imageJSON)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
c.Assert(len(imageJSON[0].RootFS.Layers), checker.GreaterOrEqualThan, 1)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue