Reputation: 337
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!
Upvotes: 25
Views: 31567
Reputation: 263896
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
Upvotes: 5
Reputation: 917
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
Upvotes: 24
Reputation: 6563
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
Upvotes: 8
Reputation: 41
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
Upvotes: 4