Docker logging in stack

I am trying to set up a simple stack where I have a graylog server and have mysql log its messages there. docker-compose.yml looks like this

version: "3"
services:
  database:
    image: mariadb:10.1
    volumes:
    - 'mariadb_data:/var/lib/mysql'
    depends_on:
    - graylog
    environment:
      MYSQL_DATABASE: "jeesample"
      MYSQL_USER: "jeeuser"
      MYSQL_PASSWORD: "password"
      MYSQL_RANDOM_ROOT_PASSWORD: "true"
    logging:
      driver: gelf
      options:
        gelf-address: "udp://graylog:12201"
  graylog:
    image: graylog2/server:2.2.3-1
    depends_on:
    - graylog-db
    - graylog-es
    environment:
      GRAYLOG_PASSWORD_SECRET: somepasswordpepper
      GRAYLOG_ROOT_PASSWORD_SHA2: 8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918
      GRAYLOG_WEB_ENDPOINT_URI: http://127.0.0.1:9000/api
    links:
    - graylog-db:mongo
    - graylog-es:elasticsearch
    ports:
    - "9000:9000"
    expose:
    - "12201/udp"
  graylog-db:
    image: mongo:3
  graylog-es:
    image: elasticsearch:2
    command: "elasticsearch -Des.cluster.name='graylog'"
    volumes:
      - graylog_es_data:/usr/share/elasticsearch/data
volumes:
  mariadb_data:
    driver: local
  graylog_es_data:
    driver: local

But when I do docker-compose up I get

ERROR: for controller Cannot start service controller: Failed to initialize logging driver: gelf: cannot connect to GELF endpoint: graylog:12201 dial udp: lookup graylog on 192.168.65.1:53: no such host

Should i open an issue for this or is there one already in github?

I had the same problem.

I don’t think you can’t tell docker to do logging using a docker service that way.

My solution was to map the graylog to a docker port like:
ports:
- 12201: 12201/udp)

and then use:
options:
gelf-address: “udp://localhost:12201”

I have not seen anything in the logs yet though.
I’d like to know if you get it to work…

How about using fluentd to forward logs from containers to the graylog2 server?

http://www.fluentd.org/guides/recipes/graylog2

https://hub.docker.com/r/graylog2/server/
https://hub.docker.com/r/fluent/fluentd/