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!

- 287
- 1
- 4
- 9
-
A docker registry is meant to contain images, not arbitrary data. Can you explain your use case, maybe there is another solution. – Henry Sep 26 '18 at 15:58
-
I’d put `docker export` on my list of commands that it’s very unusual to use. What’s your actual goal in this process? – David Maze Sep 26 '18 at 16:03
-
My use case is that firstly I ask users to upload their custom image which is exported or saved as a tar archive to a specified ftp server, then I need write a proxy program (I plan to use docker-java lib) to push these tar files to my private docker registry. The reason why I build my registry is that it's convenient for my Kubernetes cluster to download images. So I'm not sure whether I could push a tar archive to registry directly. If not, what should I do? Is there a better solution? Thanks! – fighter Sep 27 '18 at 01:53
-
Hi @DavidMaze, thanks for your answer! But why it’s very unusual to use `docker export`? If not use, how can we back-up or migrate images? Use `docker save` instead? – fighter Sep 27 '18 at 02:04
-
Why not docker import the tar and then push the resulting image? – Henry Sep 27 '18 at 04:39
-
1Thanks Herry.@Henry Yes, previously I only know the way you said, which we must firstly import or load the tar to the docker environment, while now I'd like to know whether we could push the tar directly? if docker not support, maybe I have to do what you said. – fighter Sep 27 '18 at 06:38
4 Answers
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

- 788
- 7
- 16
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

- 6,393
- 11
- 51
- 94
-
crane push does not load tags from tarball and pushes only "latest" tag. Through you can manually pass tag to push with (i.e. crane push image.tar registry.io:9090/newImage/path:someTag). – Lubo Aug 26 '22 at 08:24
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

- 31
- 2
-
I am looking for C# library. Found [this](https://github.com/CaptiveAire/Docker.Registry.DotNet) but it seems incomplete. – Farhan Ghumra Sep 27 '19 at 08:40
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

- 231,797
- 42
- 475
- 450
-
If you are using insecure (http only) registry, you have to prepare regctl to this using registry set option. See example on https://github.com/regclient/regclient/issues/268 . PS: tool is not importing tags from image. – Lubo Aug 26 '22 at 08:46