put_archive: note the data may also be a stream
The docs imply the data parameter to put_archive() must be bytes (a bytestring), which is not the case; a stream is fine too since it's passed directly to Requests.
In fact, the tests for the put_archive() feature always pass in a stream:
https://github.com/docker/docker-py/blob/a0b9c3d0b38abd4af1880ca3dde2845556dd2f70/tests/integration/api_container_test.py#L678-L679
This is also something I noticed recently. I've taken a look at the Requests adapters provided by docker-py, it doesn't look like they do anything funky which will prevent this. But I'm not really familiar with these aspects of Requests (and the adapters) to be able to say this with full confidence :)
@felixfontein Well, it works for me in production as we speak 😁
@akx out of curiosity, which transports are you using it with / did you test it with? There's unix, tcp, tcp+tls, ssh+unix, and npipe (Windows only).
@felixfontein Plain UNIX in this instance.
Hi, After a code review of request.py and Go docker client, I can confirm:
- request accepts streams (documentation: file-like objects) as data field. iter and read methods are expected.
- docker cp command with stdin as input uses such a mechanism. By the way, tar archive may be a tar gzipped archive. Sucessfully tested with 4 Go of compressed tar archive.
Rebased. Could a maintainer take a look?