Pipeing using exec_create, exec_start stdin, stdout
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.7k
- Avg merge
- 13d 8h
- Merged PRs (30d)
- 2
Description
If I use the docker CL this works perfectly for me.
echo "hello" | docker exec -i $3 sh -c 'cat >/text.txt'
Now I want to use docker-py and have this so far:
ex = cli.exec_create(container='nginx-ssl', cmd='cat >/carlskii.txt')
print cli.exec_inspect(ex)
ls = cli.exec_start(exec_id=ex["Id"], tty=True)
So how do I pass the "hello" or whatever data into the exec command so that it replicates the CL command ?
Incidentally this also works perfectly locally:
p = Popen(('docker', 'exec', '-i', 'nginx-ssl', 'sh', '-c', 'cat >text.txt'), stdin=subprocess.PIPE)
p.communicate('hello\n')
p.stdin.close()
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the exec_create and exec_start entry points shown in the issue, then read the surrounding docker-py documentation and the Docker Engine exec API behavior for stdin and output streams. Done means passing "hello" through the exec session produces the same file content as the docker CLI example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100