image
image copied to clipboard
How can I copy from a tar file stream
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
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.
now:
- upload a docker archive file by api to my server
- write this docker archive stream in a temp file.
- copy this temp file to docker repository by docker-archive transport.
expect:
- upload a docker archive file by api to my server
- 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
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.
Thanks your advice. What do you mean ‘use a registry’?
Thanks your advice. What do you mean ‘use a registry’?
https://github.com/opencontainers/distribution-spec/, e.g. https://github.com/distribution/distribution .
Please reopen if there are outstanding questions.