-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
logs() hangs after container has quit #919
Comments
minimal reproducer would be great |
Hi Tomas: config = machine.create_host_config(binds=['%s:/backup' % source], privileged=True)
restore = machine.create_container(
image='muse_backup',
command=['/restore.sh', directory, location],
entrypoint=entrypoint,
host_config=config,
)
log('Restore container ID: ' + restore.get('Id'), name)
machine.start(container=restore)
for line in machine.logs(container=restore, stream=True):
log(line.decode("utf-8").strip(), name) |
Looks like that engine did some changes. This is working for me: #!/usr/bin/python3
import docker
d = docker.AutoVersionClient()
restore = d.create_container(
image='fedora:23',
command=["python3", "-m", "http.server", "8000"],
tty=True # this does the trick
)
d.start(container=restore)
for line in d.logs(container=restore, stream=True):
print(line, end="") # engine likely turns off line buffering and sends every character |
Hi Tomas, I'll give that a try. What is AutoVersionClient? Does it take the same parameters as Client? Thanks! |
|
Thanks Tomas, I now have this working on Docker Engine 1.9.1 (I'll test 1.10.0 later). As your code comment mentioned, stream is spitting out every character without buffering. machine.start(container=backup)
line = ''
for char in machine.logs(container=backup, stream=True):
if char == '\n':
log(line, name)
line = ''
else:
line = line + char |
Seems to be working fine on 1.10.0 too. |
Same issue when streaming logs. Python 3.5
Docker version 1.12.1, build 23cf638 |
Same issue with 1.10.3, even with the |
I am still seeing this issue with the latest version of the Docker client (2.5.1). Using |
This is still happening to us, although I'm not sure on why. I have tried out the solution ( In my case this is happening with: This is happening to me with airflow just in case. I have ended up doing a polling with I have no idea why is this really failing though |
Hi,
I'm using version 1.6 of docker-py on Python 3.4.3+ on Ubuntu 15.10
This hangs after my container finishes what it's doing:
I don't want to have to return to wrapping shell commands, uggg :-(
I have seen various closed issues related to this. Am I missing some subtlety in the docs or is this a problem again?
Thanks!
The text was updated successfully, but these errors were encountered: