question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

logs() hangs after container has quit

See original GitHub issue

Hi,

I’m using version 1.6 of docker-py on Python 3.4.3+ on Ubuntu 15.10

bash# pip3 freeze | grep docker-py && python3 --version && docker version
docker-py==1.6.0
Python 3.4.3+
Client:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.4.3
 Git commit:   a34a1d5
 Built:        Fri Nov 20 17:56:04 UTC 2015
 OS/Arch:      linux/amd64

Server:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.4.2
 Git commit:   a34a1d5
 Built:        Fri Nov 20 13:20:08 UTC 2015
 OS/Arch:      linux/amd64

This hangs after my container finishes what it’s doing:

 machine.start(container=backup)
 for line in machine.logs(container=backup, stream=True):
   log(line.decode("utf-8").strip(), name)

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!

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
tedmistoncommented, Sep 8, 2017

I am still seeing this issue with the latest version of the Docker client (2.5.1). Using tty=True plus the streaming fix by @darkermatter in https://github.com/docker/docker-py/issues/919#issuecomment-181815005 fixed it for us.

1reaction
ghostcommented, Feb 9, 2016

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
Read more comments on GitHub >

github_iconTop Results From Across the Web

Find out Why Your Docker Container Keeps Crashing
Your Docker container is exiting without a useful error message? Here are a few ways to find out what's happening.
Read more >
Why Does My Docker Container Stop? - Tutorial Works
When you run a container image you've pulled from a registry like Docker Hub, you're launching a process. This process will, eventually, complete....
Read more >
docker-compose up hangs forever. How to debug?
Docker-compose seems to hang indefinitely when the system has low entropy. ... That will show you the interactive logs on the console.
Read more >
Troubleshoot ECS tasks stopping or failing to start - AWS
To identify why your tasks stopped, follow these troubleshooting steps: Check for diagnostic information in the service event log.
Read more >
Overview | Docker Documentation
This page contains information on: How to diagnose and troubleshoot Docker Desktop issues; Check the logs; Find workarounds for common problems ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found