regclient / regclient

Docker and OCI Registry Client in Go and tooling using those libraries.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature] Ability to pack multiple images into one tar export

CafeLungo opened this issue · comments

commented

The docker image save -o image.tar image:1 image:2 ... command supports multiple images to be saved into a single tarball. It would be tremendously helpful if regctl offered this capability because I've been looking for a way to save archives like this (with the deduped layers) without running a docker daemon, and the regclient toolset is very close to enabling this need.

Current Behavior

regctl image export <image_ref> [filename] [flags]

  • Only a single image_ref supported

Expected Behavior

regctl image export <image_ref...> [filename] [flags]

  • Allow multiple image_refs to be defined

Example Solution

regctl image export <image_ref...> [filename] [flags]

  • Allow multiple image_refs to be defined

Version

(paste output of `regctl version` or similar for binaries, or `docker image inspect regclient/...` on the image and paste the labels)
VCSTag:     v0.6.0
VCSRef:     9de7397da9f1c00dad5213519366002376b8d5ed
VCSCommit:  9de7397da9f1c00dad5213519366002376b8d5ed
VCSState:   clean
VCSDate:    2024-03-24T18:09:00Z
Platform:   linux/amd64
GoVer:      go1.22.1
GoCompiler: gc

Environment

  • Running as binary or container: container
  • Host platform: linux/amd64
  • Registry description: artifactory in our case, but shouldn't matter

Anything else

Ref: https://docs.docker.com/reference/cli/docker/image/save/

Unfortunately, since the filename is optional in that command, I'm not sure of a good way to do this that isn't a breaking change. It can also result in an OCI Layout being output that has some undefined behavior with multiple manifests referenced by the same "tag". This was looked at in #616, without a good resolution.

The best advice I have for this is to copy images to an OCI Layout, each with a unique tag. If copying content across an air-gap scenario, a shared storage directory or rsync is even better because layers that were previously copied would not need to be copied again. An example of what this might look like is:

# copy into an OCI Layout, flags like "--platform local" can be used to limit how much is copied
regctl image copy ghcr.io/regclient/regctl ocidir://export:regctl
regctl image copy ghcr.io/regclient/regsync ocidir://export:regsync
# copy, with optional tar, of the export directory
regctl image export ocidir://export:regctl --platform local --name ghcr.io/regclient/regctl | docker load
regctl image export ocidir://export:regsync --platform local --name ghcr.io/regclient/regsync | docker load
# or to import into a registry, the copy can be reversed
regctl image copy ocidir://export:regctl ghcr.io/regclient/regctl
regctl image copy ocidir://export:regsync ghcr.io/regclient/regsync

The image copy should have option to add the "io.containerd.image.name" annotation such that different images could be copied to the same ocidir.

The offered workaround does not solve the problem of deduplicating the layers. Being able to copy images to same ocidir (or export multiple image in same command) would allow for smaller single tar file to copy to the air-gapped device.

The offered workaround does not solve the problem of deduplicating the layers. Being able to copy images to same ocidir (or export multiple image in same command) would allow for smaller single tar file to copy to the air-gapped device.

The contents of the export folder in the example above do have the layers deduplicated. Compared to copying a tar file, the directory offers the advantage of being efficient with an rsync command that only copies the updated blobs, vs the entire tar file. However it's still possible to tar and compress the directory (note the blobs would typically already be compressed) using the tar command.

The contents of the export folder in the example above do have the layers deduplicated. Compared to copying a tar file, the directory offers the advantage of being efficient with an rsync command that only copies the updated blobs, vs the entire tar file. However it's still possible to tar and compress the directory (note the blobs would typically already be compressed) using the tar command.

Right. My bad reading.