I've re-written this question to better communicate what I'm trying to achieve.
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 >/text.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()