I have a requirement to look at the layers of the container image and check which layer is from BaseImage and which ones are from application layer. Is there a feature that could help to map the layer id to its source Dockerfile command?
PS: I tried to use dive, but unfortunately, the layer IDs shown in dive does not correlate with what is shown in docker manifest inspect for the image,
Any help would be greatly appreciated!
Mapping a container image layer to its source Dockerfile command can be challenging, especially considering that Docker images are built in layers, and these layers might not have a one-to-one correspondence with specific lines or commands in the Dockerfile. However, you can use certain techniques and tools to get some insights into the relationship between image layers and Dockerfile commands: 1.Labeling in Dockerfile Use Labels: Add labels to your Dockerfile using the LABEL instruction. These labels can provide metadata that helps you identify specific commands or lines in your Dockerfile. 2.External Tools Dive:
Dive is a tool for exploring each layer in a Docker image. It provides a detailed breakdown of the image layers, allowing you to see the filesystem changes in each layer. Container-diff:
Container-diff is a tool for analyzing and comparing container images. It can help you identify the differences between images, including changes introduced by each layer.
3.Docker History:
Use the docker history command to inspect the layers of an image and identify which commands contributed to each layer.