When I inspect the image elasticsearch@sha256:92fca5d2fe565f97ce11209fcd057e95f3f18287757be680dc76590788b84fcf, I am getting the layer information below. There are many repeated layers. Why is this happening?
"RootFS": {
"Type": "layers",
"Layers": [
"sha256:12e469267d21d66ac9dcae33a4d3d202ccb2591869270b95d0aad7516c7d075b",
"sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef",
"sha256:0d78baeff42ffece0dedcf64de6e1fea1e867e274fa36e1ebc5a4ab6af5d45f1",
"sha256:436c692f222877b88632550ce3e11968d3a8d0916d3b4fc6f33d713196a2b891",
"sha256:8e3cccdc82291f3ff62692f62afbcc4455a34a3f8d81b8c5d4775b4fe68c140e",
"sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef",
"sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef",
"sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef",
"sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef",
"sha256:0bdcf95ed87616883f5b746d24ecb71461b3f76b280480282e1f03e97bc7b68b",
"sha256:cbbec3d4fa2d4294d5ecd93fd945634ae7eb992df72b03dff645af0f854f9b19",
"sha256:f87abd9c74bf58896dc6fca32a8a5e06de65509116fc7c24b46c38df394a5d81",
"sha256:a8a2696157358397c52f5f8da7504735f38b041745c4bffb776f8316c2ce6ec7",
"sha256:66ed94e706a71223e5db8d94580750ad110de4d73a6cce56f7d229ece8daff4c",
"sha256:bbaa010363187219166f97c7ac612de3514a04a94fda17d9625e0dddb48120cd",
"sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef",
"sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef",
"sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef",
"sha256:5d248fc15d0e269fc8c45f4812444eae595b0f4c39d6512f6cf2a014ccdf0ff0",
"sha256:22eea9de37a553c8981aff7d65259a368fe2343babb49fd2fef55cd94c3d52d9",
"sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef",
"sha256:5f2c80f758e56ff4ffc6ee807047ae7ad6391270e08c9851d72588906fec6fab",
"sha256:4c9c17a09c33c40659e585bfd15f3ea4e2f762fcd95079b3940d716818e1277d",
"sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef",
"sha256:92d6e040a0969db56ab7766679f10c2c64e9b051d0855f12c02c5ba5030b6a33",
"sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef",
"sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef",
"sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef"
]
},
CodePudding user response:
This is an extremely old image for elasticsearch 2.1.0 built back in 2015. Back then, the manifest schema (v1) had a container and layer created for each change, including metadata only changes that don't result in any change to the filesystem:
$ regctl manifest get elasticsearch@sha256:92fca5d2fe565f97ce11209fcd057e95f3f18287757be680dc76590788b84fcf
{
"schemaVersion": 1,
"name": "library/elasticsearch",
"tag": "2.1.0",
"architecture": "amd64",
"fsLayers": [
{
"blobSum": "sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4"
},
{
"blobSum": "sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4"
},
{
"blobSum": "sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4"
},
{
"blobSum": "sha256:fba6c215477099bd3c0cbbb26a3adec50be32d5794ac3c683c7efe5437665aba"
},
{
"blobSum": "sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4"
},
{
"blobSum": "sha256:338829b4f325b9c13a2ad15381eeec2958e85dcf462df329a14514673d14c114"
},
{
"blobSum": "sha256:a0aa250d5025f9051d2854be2cc30fbb3ef757e7e2c0cd0568c056647ff35240"
},
{
"blobSum": "sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4"
},
{
"blobSum": "sha256:a49c2f7dfc82def14c51751e3cd36176812dc478bb76444938bf11f3d36d8fb8"
},
{
"blobSum": "sha256:4ccacd6bfa15f3ea1c60b284a47b4a8d5b0c50e3525cee39de59e0fbc89984dc"
},
{
"blobSum": "sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4"
},
{
"blobSum": "sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4"
},
{
"blobSum": "sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4"
},
{
"blobSum": "sha256:58d1e1dd0f86b73fd9687a779fc85f35327f4734a1dc1bb81fc05ca4fe96b15b"
},
{
"blobSum": "sha256:5ddab515df02c5c1abbfafa886683eff3d428af67196a168038ceceff2197547"
},
{
"blobSum": "sha256:a91742ab17fc79d25e9cb8e39dc5ecc987648a92af1ef6599e7fc90bf4356f1a"
},
{
"blobSum": "sha256:d34e22497ac0e2e4213dbd2c55013b79d006d0ed06dd76650dc11f1b22bc943f"
},
{
"blobSum": "sha256:20ae76d672fc2b0ab4c6698434e92773d1ce13708b12e71e9c2f70eef2e8e7fb"
},
{
"blobSum": "sha256:2464058c255a21e49f60906f3d012584b359be2839a785c59ea2d216998eff90"
},
{
"blobSum": "sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4"
},
{
"blobSum": "sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4"
},
{
"blobSum": "sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4"
},
{
"blobSum": "sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4"
},
{
"blobSum": "sha256:03f01b5df3859d775ef5c36d4c417b132d9bbd963355db4437b2d49fc70435f2"
},
{
"blobSum": "sha256:78b9e3c01ea48aaa24c846b994ce9cd08b89bbda022dd3af29795dad64206533"
},
{
"blobSum": "sha256:816152842605fe3ede1dc7c47f33e641f74cb4ae0d5c51a6c19cc8d85da934f3"
},
{
"blobSum": "sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4"
},
{
"blobSum": "sha256:d4bce7fd68df2e8bb04e317e7cb7899e981159a4da89339e38c8bf30e6c318f0"
}
],
...
$ regctl blob get elasticsearch sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4 | tar -tvzf -
$
If you look at newer images, the v2 schema adds the ability to flag a history step as an empty layer, so the rootfs has no entry for those.