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!
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
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
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
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
© 2022 - 2024 — McMap. All rights reserved.
docker export
on my list of commands that it’s very unusual to use. What’s your actual goal in this process? – Masterfuldocker export
? If not use, how can we back-up or migrate images? Usedocker save
instead? – Consanguineous