You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 19, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Nov 19, 2026. It is now read-only.
copy: dest !compression not complied with if source is compressed #192
This is a bit of a weird issue, but it's something that is exposed if you apply #148. Effectively because docker-daemon (and thus docker/tarfile) return the set of DiffIDs as the LayerInfos for a particular schema, you end up with GetBlob(diffid) giving you the wrong hash.
I'm not really sure how we should handle this, because I don't think the docker save-style archives don't contain enough nicely-formatted information about the compressed layer digests for us to be able to switch. Should we just un-gzip layers?
Ah, sorry this is actually caused by the automatic compression/decompression done during copying. It looks like ShouldCompressLayers isn't being handled properly, causing a copy from docker-daemon -> docker-archive to work, but docker -> docker-archive to not work.
changed the title [-]docker-daemon uses DiffIDs even though blobs are gzip'd[/-][+]copy: dest !compression not complied with if source is compressed[/+]on Dec 26, 2016
So, to be explicit, am I correct that the issue is:
skopeo copy docker://… docker-archive:$x creates a valid (i.e. consumable by docker load) tarball, which contains compressed layers and DiffIDs of uncompressed data [but no record of the digests of the compressed data]
skopeo copy docker-archive:$x … then fails, because it uses the DiffIDs to identify layers but the actual files are compressed
?
Yeah, that’s pretty ugly. (For the record, it is not an issue for docker-daemon:, because the daemon transparently unpacks the compressed layers and verifies DiffIDs on docker load, and on docker save it always creates uncompressed layers.)
Now, whether we should be creating and/or accepting tarballs which contain compressed layers is really a matter of definition; AFAIK the tarball format is not formally documented, so strictly speaking we can do anything, e.g. one (or more) of the following:
Always uncompress layers in archiveImageDestination so that the DiffID matches in the tarball. May waste space.
Always uncompress layers in archiveImageSource so that the DiffID matches during verification. Fairly likely wastes time.
Teach the copy.go digest verification code about some digests being of the compressed data / of the uncompressed data (we already have ugly code to compute DiffID values for compressed tarballs).
Teach copy.go that some sources have expected digest verification failures. (That’s pretty risky and ugly.)
I guess my weak preference would be 2. or 3., because that makes any tarball acceptable to docker load also acceptable to docker-archive:. OTOH 1. is probably a bit easier to implement.
A particular concern, of course, is signatures: whether we verify, what we verify, and who decides what we verify, all matters. Right now, in the case of the docker-daemon: format, this is academic because the format can’t record or provide signatures, but we do intend to integrate that $somehow fairly soon. I’m afraid right now I don’t have a completely clear idea what that would look like and what that would mean for the whole problem space. (It does seem attractive to be able to authenticate the config.json from the signature $somehow, and then use the DiffID values from there to authenticate layers; rebuilding compressed tarballs to match expected digests of compressed data is pretty much a non-starter, see #157 .)
Thinking about this a bit more, the abstraction we impose on an ImageSource forces us to create an artificial manifest for GetManifest; and that manifest must refer to blobs using the same digests which we return in PutBlob. So, unless we invent a new manifest schema, options 3 and 4 are not viable.
(OTOH we also now have option 5: rework the abstraction, perhaps to expose the tar manifest.json as a new kind of manifest supported by containers/image/image and using the UpdatedImage mechanism for manifest conversion from/to schema2 and others. But that is a manifest of the tar file which may contain several images, it is a poor fit for an “image manifest”, and defining a single manifestItem to be the tar image manifest would be inventing a completely new format.)
So right now I am leaning towards either 2 (silently uncompress blobs in archiveImageSource.GetBlob) or 2a (when collecting the data for archiveImageSource.GetManifest, use the available DiffID if we detect the blob as uncompressed, and compute a new digest of the compressed data if the blob is compressed or unrecognizable).
@mtrmac Alright I'm back. Sorry for the extended silence.
I would prefer that we just decompress blobs when we're an ImageSource -- which means that there's no messing around with manifests or other structures -- we are just providing a different blob to the one we were originally given.
Handling signatures is a bit of an issue, but ultimately because of the hacks done with DiffIDs we will have to modify something. And that something will always be either the manifest or the actual blobs. I'd prefer if we maintain the invariant of identifiers of layers being content-addressible...
Currently I'm reworking #193 to make my current solution better.
Activity
cyphar commentedon Dec 26, 2016
Ah, sorry this is actually caused by the automatic compression/decompression done during copying. It looks like
ShouldCompressLayersisn't being handled properly, causing a copy fromdocker-daemon->docker-archiveto work, butdocker->docker-archiveto not work.cyphar commentedon Dec 26, 2016
Ah, it's because
copy/copy.godoesn't actually appear to decompress layers if the target layer doesn't accept compression. Which is a bit ... odd.[-]docker-daemon uses DiffIDs even though blobs are gzip'd[/-][+]copy: dest !compression not complied with if source is compressed[/+]mtrmac commentedon Jan 7, 2017
So, to be explicit, am I correct that the issue is:
skopeo copy docker://… docker-archive:$xcreates a valid (i.e. consumable bydocker load) tarball, which contains compressed layers and DiffIDs of uncompressed data [but no record of the digests of the compressed data]skopeo copy docker-archive:$x …then fails, because it uses the DiffIDs to identify layers but the actual files are compressed?
Yeah, that’s pretty ugly. (For the record, it is not an issue for
docker-daemon:, because the daemon transparently unpacks the compressed layers and verifies DiffIDs ondocker load, and ondocker saveit always creates uncompressed layers.)Now, whether we should be creating and/or accepting tarballs which contain compressed layers is really a matter of definition; AFAIK the tarball format is not formally documented, so strictly speaking we can do anything, e.g. one (or more) of the following:
archiveImageDestinationso that the DiffID matches in the tarball. May waste space.archiveImageSourceso that the DiffID matches during verification. Fairly likely wastes time.copy.godigest verification code about some digests being of the compressed data / of the uncompressed data (we already have ugly code to compute DiffID values for compressed tarballs).copy.gothat some sources have expected digest verification failures. (That’s pretty risky and ugly.)I guess my weak preference would be 2. or 3., because that makes any tarball acceptable to
docker loadalso acceptable todocker-archive:. OTOH 1. is probably a bit easier to implement.mtrmac commentedon Jan 7, 2017
A particular concern, of course, is signatures: whether we verify, what we verify, and who decides what we verify, all matters. Right now, in the case of the
docker-daemon:format, this is academic because the format can’t record or provide signatures, but we do intend to integrate that $somehow fairly soon. I’m afraid right now I don’t have a completely clear idea what that would look like and what that would mean for the whole problem space. (It does seem attractive to be able to authenticate theconfig.jsonfrom the signature $somehow, and then use the DiffID values from there to authenticate layers; rebuilding compressed tarballs to match expected digests of compressed data is pretty much a non-starter, see #157 .)mtrmac commentedon Jan 10, 2017
Thinking about this a bit more, the abstraction we impose on an
ImageSourceforces us to create an artificial manifest forGetManifest; and that manifest must refer to blobs using the same digests which we return inPutBlob. So, unless we invent a new manifest schema, options 3 and 4 are not viable.(OTOH we also now have option 5: rework the abstraction, perhaps to expose the tar
manifest.jsonas a new kind of manifest supported bycontainers/image/imageand using theUpdatedImagemechanism for manifest conversion from/to schema2 and others. But that is a manifest of the tar file which may contain several images, it is a poor fit for an “image manifest”, and defining a singlemanifestItemto be the tar image manifest would be inventing a completely new format.)So right now I am leaning towards either 2 (silently uncompress blobs in
archiveImageSource.GetBlob) or 2a (when collecting the data forarchiveImageSource.GetManifest, use the available DiffID if we detect the blob as uncompressed, and compute a new digest of the compressed data if the blob is compressed or unrecognizable).Merge pull request containers#192 from rhatdan/install
cyphar commentedon Jan 30, 2017
@mtrmac Alright I'm back. Sorry for the extended silence.
I would prefer that we just decompress blobs when we're an
ImageSource-- which means that there's no messing around with manifests or other structures -- we are just providing a different blob to the one we were originally given.Handling signatures is a bit of an issue, but ultimately because of the hacks done with
DiffIDswe will have to modify something. And that something will always be either the manifest or the actual blobs. I'd prefer if we maintain the invariant of identifiers of layers being content-addressible...Currently I'm reworking #193 to make my current solution better.
mtrmac commentedon Jan 30, 2017
ACK.