Open ChandlerSwift opened 5 years ago
Standard input is looking tough.
It looks like there's no official support in the Docker python library for it, though not for lack of trying: https://github.com/docker/docker-py/issues/73 https://github.com/docker/docker-py/pull/239 Somewhat related: https://github.com/docker/docker-py/issues/390 https://github.com/docker/docker-py/pull/946 Simply trying the fixes listed there don't seem to close standard input when completed, though I could be missing something (taken from https://github.com/docker/docker-py/pull/239#issuecomment-106958176):
container = client.api.create_container(
image="debian",
command="cat",
stdin_open=True)
client.api.start(container)
s = client.api.attach_socket(container, params={'stdin': 1, 'stream': 1})
s._sock.send("Hello, world! This is on stdin!")
s.close()
This does provide input to standard input, but s.close()
(and s._sock.close()
, which seems to do the same thing?) don't send whatever EOF is necessary to close standard input, and cat hangs waiting for more input.
More info/potential solutions: https://stackoverflow.com/questions/26843625/how-to-send-to-stdin-of-a-docker-py-container
Right now, none of these are working.