What I'm trying to achieve is to redirect python print from one docker container to the other (without any modification inside python code), with graylog2 (I'm currently using older version, all in one).

So my first docker instance contains graylog server. I created second instance with Dockerfile, using Ubuntu and included simple script that prints current time:

from datetime import datetime
import time

date = datetime.now()
print(str(date.day) + '/' + str(date.month) + '/' + str(date.year))
while True:
   date = datetime.now()
   print(str(date.hour) + ':' + str(date.minute) + ':' + str(date.second))

I'm using command below to start graylog

docker run -t -p 9000:9000 -p 12201:12201 graylog2/allinone

and to start second container and run my script:

docker run --log-driver=gelf --log-opt gelf-address=udp:// test python -i ../test.py

I'm trying to send my logs to GELF UDP, not sure if it's the right way, because there are no logs whatsoever, no matter which address/port I choose. For now I can't even log simple echo from bash, but I'm not sure where's the problem itself.

My 'input' overview:

My 'input' overview


So I managed to make it work finally. My problem was that I didn't specify which port udp protocol will use - in this case 12201. To fix this, you need to start it like this:

docker run -t -p 9000:9000 -p 12201:12201/udp graylog2/allinone
  • It's strange why no one vote this good answer, maybe because allinone is deprecated now.
    – RandomEli
    Sep 6 '17 at 19:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.