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 using 2.0.1 version).
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 import sys 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)) time.sleep(1) sysy.stdout.flush()
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. I was following this guide on docker hub, including part with persisting log data (it means I'm using this default docker-compose.yml file). I start my second container with:
docker run --log-driver=gelf --log-opt gelf-address=udp://0.0.0.0:12201 test python -i -u test.py
[link] [comments]