To check the SHA numbers (hashes) of Docker image layers, you can use the docker inspect command. Here’s how to do it:
Steps to Check SHA Numbers
Open Your Terminal: Make sure you have Docker installed and running.
Run the Inspect Command: Use the following command, replacing
image_namewith the name of your Docker image:docker inspect --format='{{.RootFS.Layers}}' image_nameFor example, if your image is named
custom-nginx, you would run:docker inspect --format='{{.RootFS.Layers}}' custom-nginxView the Output: The command will output a list of SHA256 hashes corresponding to the layers of the specified image. It will look something like this:
[ "sha256:abc123...", "sha256:def456...", ... ]
Example
If you want to inspect the SHA numbers of an image named my-image, you would execute:
docker inspect --format='{{.RootFS.Layers}}' my-image
Additional Information
Full Inspect Command: If you want more detailed information about the image, you can simply run:
docker inspect my-imageThis will provide a comprehensive JSON output, including the SHA numbers under the
RootFSsection.Using jq: If you have
jqinstalled, you can format the output for better readability:docker inspect my-image | jq '.[].RootFS.Layers'
Summary
By using the docker inspect command, you can easily check the SHA numbers of the layers in a Docker image. This can help you verify integrity, troubleshoot issues, or manage layers effectively.
If you have more questions or need further assistance, feel free to ask!
