docker-py icon indicating copy to clipboard operation
docker-py copied to clipboard

container.logs seems to no stream logs when the container is started without the tty option

Open gpolaert opened this issue 8 years ago • 7 comments

I'm not sure if it's an issue.

I try to stream container logs using the docker-py client. I noticed I have no logs when my container is started without -t.

logs = container.logs(stream=True, follow=True, stdout=True, stderr=False, tail=0)

Even if I can show them using this command docker logs -f <container>

gpolaert avatar Jan 17 '17 11:01 gpolaert

Could someone help me to understand?

gpolaert avatar Jan 24 '17 14:01 gpolaert

Did you try to tinker switches? I would definitely start with:

logs = container.logs(stream=True, follow=True, stdout=True, stderr=True, tail='all')

It also depends what kind of application you are running in the container.

Also bear in mind that

$ docker logs -f <container>

is not an equivalent of

logs = container.logs(stream=True, follow=True, stdout=True, stderr=False, tail=0)

TomasTomecek avatar Feb 20 '17 10:02 TomasTomecek

Run into a similar problem. @TomasTomecek can you explain the difference between the two, and also what's the difference between stream and follow? What happens if you specify one or both? Why does stream not follow? Does follow automatically stream? What is returned when both are specified?

danqing avatar Aug 27 '17 20:08 danqing

@danqing since my comment is 6 months old, I forgot everything; I would need to check sources to answer, so please see the sources for more info

TomasTomecek avatar Aug 29 '17 19:08 TomasTomecek

Yeah the source is pretty confusing too :( I've hacked a solution, but it looks like the logging part of this library still needs some significant improvements to work reliably.

danqing avatar Aug 29 '17 19:08 danqing

8 years later, this issue is affecting TrueNAS Scale, and they referred me to this issue, saying they "depend on upstream to fix it for them".

kode54 avatar Apr 23 '25 05:04 kode54

This is finally resolved for me on version ElectricEel-24.10.2.2.

TannerLivingston avatar Jun 21 '25 23:06 TannerLivingston