Docker - 使用GELF日志驱动程序登录Graylog2容器会引发错误

时间:2017-04-05 12:01:34

标签: logging docker docker-compose graylog2

我想设置Docker系统来运行MongoDB,Elasticsearch,Graylog2和我的微服务,并将所有日志转发到Graylog服务器。我已经制作了一个docker-compose.yml文件来完全运行它:

version: '2'

services:
    elasticsearch:
        image: "elasticsearch:2"
        command: "elasticsearch -Des.cluster.name='graylog'"
        volumes:
          - elasticsearch:/usr/share/elasticsearch/data
        ulimits:
          memlock:
            soft: -1
            hard: -1
          nofile:
            soft: 65536
            hard: 65536
        ports:
            - "9200:9200"
    graylog:
        image: graylog2/server:latest
        environment:
            GRAYLOG_PASSWORD_SECRET: somepasswordpepper
            GRAYLOG_ROOT_PASSWORD_SHA2: 8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918
            GRAYLOG_WEB_ENDPOINT_URI: http://127.0.0.1:9000/api
        links:
            - mongodb:mongo
            - elasticsearch:elasticsearch
        ports:
            - "9000:9000"
            - "12201/udp:12201/udp"
            - "1514/udp:1514/udp"

    mongodb:
        build: ./docker/mongo
        ports:
            - "27017:27017"
        volumes:
            - mongodb:/data/db

    omsevents:
        build:
            context: ./oms-events
        links:
            - mongodb
        logging:
            driver: "gelf"
            options:
                gelf-address: "udp://graylog:12201"
                tag: "oms-events"

volumes:
    mongodb:
        driver: "local"
    elasticsearch:
        driver: "local"

./docker/mongo./oms-events文件夹包含用于构建图像的Dockerfiles。

问题是,如果我运行它会引发错误:

ERROR: for omsevents  Cannot start service omsevents: Failed to initialize logging driver: gelf: cannot connect to GELF endpoint: graylog:12201 dial udp: lookup graylog: no such host
ERROR: Encountered errors while bringing up the project.

如果我从logging配置中移除了oms-events块,这将有效,但这不会将日志转发给GELF。

我猜这种情况正在发生,因为Graylog和Elasticsearch在oms-events服务启动时没有设置,这就是为什么它无法连接到它。但我不确定。

我该如何解决这个问题?

0 个答案:

没有答案