'How to push a tar archive to private docker registry?

Now I have such a requirement,firstly I need export a container’s filesystem as a tar archive, then I need push this tar to my own docker registry.So could I push a tar file which is exported by using docker export image_name to my private registry.Before this I only know I could push a local image to registry by using docker push image_name. Thanks!



Solution 1:[1]

If you don't want to use any external tools, you can use a combination of:

docker image load --input image.tar.gz # this will output the original image name
docker image tag original-registry.example.org/original-image-name:0.0.1 new-registry.example.com/new-image-name:0.0.1
docker push new-registry.example.com/new-image-name

Solution 2:[2]

I've just released the following library:

https://pypi.org/project/dockertarpusher/0.16/

I've also struggled with volume the docker socket into container that needs only to repush tar image, so that was the reason for this library

Solution 3:[3]

The crane tool seems to have this functionality:

crane pull - Pull a remote image by reference and store its contents in a tarball
crane push - Push image contents as a tarball to a remote registry

Solution 4:[4]

The three tools I know of for working with registries without a docker engine are crane from Google, skopeo from RedHat, and regclient from myself.

The workflow that's needed is to extract the tar, push each layer and config, and then push the manifests. OCI's distribution-spec includes details on the registry API, but realize that the authentication doesn't have a spec over there (at least not yet), and there are different tar files whether you are talking about a docker export, docker save, or an OCI layout. There's also whether the tar file has been compressed.

For the latter two formats, you can use regctl image import from the regclient project. E.g.:

regctl image import localhost:5000/project:tag image.tar

Or to go the other way and create an export (that is a merge of the docker save and OCI layouts):

regctl image export localhost:5000/project:tag image.tar

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Falko Menge
Solution 2 Adam Ra?niewski
Solution 3 paleozogt
Solution 4 BMitch