mcollina / docker-loghose

Collect all the logs from all docker containers
MIT License
63 stars 15 forks source link

Docker Hello World outputs no logs #2

Closed l15k4 closed 9 years ago

l15k4 commented 9 years ago

Hi,

1)

docker run --rm -v /var/run/docker.sock:/var/run/docker.sock matteocollina/docker-loghose

> docker-loghose@0.6.0 start /usr/src/app
> ./loghose.js

2)

$ docker run --rm ubuntu:14.04 /bin/echo 'Hello world'
Hello world
$ docker run --rm busybox /bin/echo 'Hello world'
Hello world
$ docker run --rm busybox /bin/echo 'Hello world'
Hello world
$ docker run --rm ubuntu:14.04 /bin/echo 'Hello world'
Hello world

But loghose container yields no logs at all... I was playing with it for a while and a single log line came out :

{"v":0,"id":"5f90c25c52a2","image":"busybox","name":"insane_thompson","line":"Hello world"}

But it was only when I ran the busybox:latest command for the first time... Then just silence

$ docker -v
Docker version 1.7.1, build 786b29d
$ uname -a
Linux lisak 3.16.0-34-generic #47~14.04.1-Ubuntu SMP Fri Apr 10 17:49:16 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
mcollina commented 9 years ago

There is a slight delay after which the logs are forwarded. Would you like to sort that out? It shouldn't be too hard.

Basically for freshly minted container we need to fetch the full logs.

l15k4 commented 9 years ago

Hey, I don't think it is in my power, I've never done anything with node.js and I don't understand what delay you are talking about. It doesn't yield any logs no matter when I run loghose or after how long I start log anything.

mcollina commented 9 years ago

@StephenHynes7 is it all working in docker-logentries, right?

l15k4 commented 9 years ago

@mcollina No it doesn't work in there. The reason why it doesn't work in docker-logentries is imho because of this issue :-)

cammellos commented 9 years ago

@mcollina I have noticed a similar issue on one of my machines ( same set up on worked on a different one though ), it seemed like only the payload and not the headers were passed to docker-loghose, but I can have a closer look and see if I can replicate it.

mcollina commented 9 years ago

@cammellos that would be awesome, thanks! Just to confirm, this is working for you, right?

cammellos commented 9 years ago

it's working ok on all my machines but one, where I noticed a similar issue. But the docker installation is somewhat broken there, so I figured that that might have been the problem. I will need to have a closer look at it now that a similar issue has been reported.

On Tue, Aug 25, 2015 at 10:46 AM, Matteo Collina notifications@github.com wrote:

@cammellos https://github.com/cammellos that would be awesome, thanks! Just to confirm, this is working for you, right?

— Reply to this email directly or view it on GitHub https://github.com/mcollina/docker-loghose/issues/2#issuecomment-134541160 .

l15k4 commented 9 years ago

Btw it doesn't happen only when you do :

$ docker run --rm ubuntu:14.04 /bin/echo 'Hello world'
Hello world
$ docker run --rm busybox /bin/echo 'Hello world'
Hello world

It happens even if you start the container, got to shell and do echo 'Hello world' ... there is still no output from loghose...

agassner commented 9 years ago

I think this issue might be related to the piece of code https://github.com/mcollina/docker-allcontainers/blob/master/allcontainers.js#L31-L37

As far as I understood for containers that are not running in the background (-d) or in interactive mode (-i) - ie busybox and ubuntu - will start and stop almost instantly.

try this:

docker run --rm busybox /bin/sh -c 'echo "Hello world!"'

and then

docker run --rm busybox /bin/sh -c 'sleep 3; echo "Hello world!"'

You should see the log message when you run with sleep 3

mihaidma commented 9 years ago

I tried loghose on 4 scenarios:

The issue did not reproduce on my machine, I could see the logs.

More info would be needed to investigate this particular case. @agassner 's explanation might point in the right direction.

Just a detail: the docker-logentries container does not output anything, you must check on the Logentries account if logs are sent or not.

l15k4 commented 9 years ago

It all works now, docker-logentries too, thank you all guys.