【问题标题】:Docker container running Bind9 - Logs files remains empty运行 Bind9 的 Docker 容器 - 日志文件仍然为空
【发布时间】:2018-11-14 19:30:05
【问题描述】:

我有一个运行 Bind9 的 Docker 容器。

在容器内named 正在与bind 用户一起运行

bind         1     0  0 19:23 ?        00:00:00 /usr/sbin/named -u bind -g

在我的named.conf.local 我有

channel queries_log {
    file "/var/log/bind/queries.log";
    print-time yes;
    print-category yes;
    print-severity yes;
    severity info;
};

category queries { queries_log; };

启动容器后,会创建日志文件

-rw-r--r-- 1 bind bind 0 Nov 14 19:23 queries.log

但它始终是空的。

另一方面,使用docker logs ... 仍然可以看到“查询”日志

14-Nov-2018 19:26:10.463 client @0x7f179c10ece0 ...

在没有 Docker 的情况下使用相同的配置可以正常工作。

我的docker-compose.yml

version: '3.6'
services:
    bind9:
        build: .
        image: bind9:1.9.11.3
        container_name: bind9
        ports:
          - "53:53/udp"
          - "53:53/tcp"
        volumes:
            - ./config/named.conf.options:/etc/bind/named.conf.options
            - ./config/named.conf.local:/etc/bind/named.conf.local

我的Dockerfile

FROM ubuntu:18.04
ENV BIND_USER=bind \
    BIND_VERSION=1:9.11.3
RUN apt-get update -qq \
&& DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends install -y \
 bind9=${BIND_VERSION}* \
 bind9-host=${BIND_VERSION}* \
 dnsutils \
&&  rm -rf /var/lib/apt/lists/*
COPY entrypoint.sh /sbin/entrypoint.sh
RUN chmod 755 /sbin/entrypoint.sh
ENTRYPOINT ["/sbin/entrypoint.sh"]
CMD ["/usr/sbin/named"]

【问题讨论】:

  • 如何运行容器? docker run? docker-compose?
  • @Alex,我编辑了我的问题。

标签: docker logging bind9


【解决方案1】:
   -f
       Run the server in the foreground (i.e. do not daemonize).

   -g
       Run the server in the foreground and force all logging to stderr.

尝试使用 -f 而不是 -g。

【讨论】:

    猜你喜欢
    • 2021-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-19
    • 2022-09-29
    • 1970-01-01
    • 2016-12-06
    相关资源
    最近更新 更多