Hi,
I read your the documentation about docker-py but it seems that there is no way to copy something into a container, right? That's a feature what I'd really like and need.
If there is a different way to do so, please tell me. Temporarily, I stick with a simple shell command execution.
PS: If this is the wrong place to ask for something, please tell me where I can ask questions since I tried to join your channels on freenode, but it seems I must get the Developer-Status to join.
OK, I found put_archive as an option, but I don't understand why it's better to specify a TAR archive? Don't want to pack a 429 Bytes file into an archive.
Related: https://github.com/docker/docker-py/issues/983
That's how the API is designed. Feel free to open an issue on docker/docker if there's an improvement you have in mind. Here's the remote API call:
https://docs.docker.com/engine/reference/api/docker_remote_api_v1.22/#extract-an-archive-of-files-or-folders-to-a-directory-in-a-container
Yes, put_archive is the way to do this. As @TomasTomecek said, that's how the remote (docker engine) API works - it might seem tedious when working with a single file, but it's obviously a good solution when you want to copy a wide range of things from files big and small to entire directory structures.
Here is a gist of what I do to put a password file into a container:
https://gist.github.com/zbyte64/6800eae10ce082bb78f0b7a2cca5cbc2
Hope it helps!
Hello gents, Let me join to this conversation and I share my feelings with you. I felt the same confusion when I had to archive a single file just in order to copy it into the archive. I am sure the above code snippet from gist can be added as an additional method on docker client. Do you want me to open a separate Issue/FR for this?
I've just had to do the same awkward archiving of a file before passing the bytes through as the data.
I also think that it would be nice if the Docker client could handle this as it's probably much more common that people will have a string to go in a file/file/directory of files, that they want to inject into a running container, than having a pre-made archive with them in. However, given the docker API, I do see why only the latter is currently supported.
Did you open a separate pull request for this feature @borismod?
@colin-nolan no I haven't open a separate issue for this one.
Most helpful comment
Here is a gist of what I do to put a password file into a container:
https://gist.github.com/zbyte64/6800eae10ce082bb78f0b7a2cca5cbc2
Hope it helps!