I tried to find this information around the Docker official docs, but had no success.
Which pieces of information does Docker take into account when calculating the hash
Thanks @thaJeztah. Answer is in https://gist.github.com/aaronlehmann/b42a2eaf633fc949f93b#id-definitions-and-calculations
layer.DiffID: ID for an individual layer
Calculation: DiffID = SHA256hex(uncompressed layer tar data)
layer.ChainID: ID for a layer and its parents. This ID uniquely identifies a filesystem composed of a set of layers.
Calculation:
image.ID: ID for an image. Since the image configuration references the layers the image uses, this ID incorporates the filesystem data and the rest of the image configuration.
Calculation: SHA256hex(imageConfigJSON)