image icon indicating copy to clipboard operation
image copied to clipboard

How can I copy from a tar file stream

Open zuzuviewer opened this issue 1 year ago • 6 comments

How can I copy image from a tar file stream not a tar file. My server have a image upload api use multipart/form, it receive a docker image tar file stream, now I must create a temp file to save image and then copy it to backend repository, how can I directly copy upload stream to backend repository

zuzuviewer avatar Mar 01 '24 02:03 zuzuviewer

Thanks for reaching out.

Please be more specific about what you are trying to do. Steps to reproduce / actual results / expected results?

If this is about the docker-archive: transport, consuming that inherently requires random access (or, equivalently, extracting the archive to a filesystem, and then accessing files in random order), so some kind of staging mechanism is inevitable.

mtrmac avatar Mar 01 '24 15:03 mtrmac

now:

  1. upload a docker archive file by api to my server
  2. write this docker archive stream in a temp file.
  3. copy this temp file to docker repository by docker-archive transport.

expect:

  1. upload a docker archive file by api to my server
  2. copy this docker archive stream to docker repository.

I want to copy stream to docker repository directly otherwise write stream to temp file, then copy from this temp file. Because temp file will use operate system buffer/cache

zuzuviewer avatar Mar 05 '24 02:03 zuzuviewer

As already described above, that’s just not possible. You can provide a stream to docker-archive (using a named pipe, or perhaps /dev/fd/…), but docker-archive: is going to create that temporary file internally.

In general, I would recommend not building any workflows around the docker-archive: format in the first place; use a registry. I realize that’s not always possible or trivial to change, but it is a better design, eliminating this performance issue, for example.

mtrmac avatar Mar 05 '24 12:03 mtrmac

Thanks your advice. What do you mean ‘use a registry’?

zuzuviewer avatar Mar 08 '24 14:03 zuzuviewer

Thanks your advice. What do you mean ‘use a registry’?

zuzuviewer avatar Mar 08 '24 14:03 zuzuviewer

https://github.com/opencontainers/distribution-spec/, e.g. https://github.com/distribution/distribution .

mtrmac avatar Mar 08 '24 18:03 mtrmac

Please reopen if there are outstanding questions.

mtrmac avatar May 13 '24 14:05 mtrmac